Remove dead test classes.

This commit is contained in:
LexManos 2020-06-03 17:46:30 -07:00
parent f24991f3bb
commit 0c0603dc91
133 changed files with 0 additions and 15903 deletions

View File

@ -1,135 +0,0 @@
/*
* Minecraft Forge
* Copyright (c) 2016-2019.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation version 2.1
* of the License.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
package net.minecraftforge.debug.block;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
import net.minecraft.block.TNTBlock;
import net.minecraft.entity.EntityClassification;
import net.minecraft.entity.EntityType;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.item.TNTEntity;
import net.minecraft.item.BlockItem;
import net.minecraft.item.Item;
import net.minecraft.network.IPacket;
import net.minecraft.util.Direction;
import net.minecraft.util.SoundCategory;
import net.minecraft.util.SoundEvents;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.Explosion;
import net.minecraft.world.World;
import net.minecraftforge.eventbus.api.IEventBus;
import net.minecraftforge.fml.RegistryObject;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.Mod.EventBusSubscriber.Bus;
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
import net.minecraftforge.fml.network.NetworkHooks;
import net.minecraftforge.registries.DeferredRegister;
import net.minecraftforge.registries.ForgeRegistries;
/*
@Mod(CustomTNTTest.MODID)
@Mod.EventBusSubscriber(modid = CustomTNTTest.MODID, bus = Bus.MOD)
public class CustomTNTTest {
static final String MODID = "custom_tnt_test";
static final String BLOCK_ID = "test_tnt";
private static final DeferredRegister<Block> BLOCKS = new DeferredRegister<>(ForgeRegistries.BLOCKS, MODID);
private static final DeferredRegister<Item> ITEMS = new DeferredRegister<>(ForgeRegistries.ITEMS, MODID);
private static final DeferredRegister<EntityType<?>> ENTITIES = new DeferredRegister<>(ForgeRegistries.ENTITIES, MODID);
public static final RegistryObject<TNTBlock> CUSTOM_TNT = BLOCKS.register(BLOCK_ID, () -> new CustomTNTBlock(Block.Properties.from(Blocks.TNT)));
public static final RegistryObject<EntityType<CustomTNTEntity>> CUSTOM_TNT_ENTITY = ENTITIES.register(BLOCK_ID, () -> EntityType.Builder
.create((EntityType.IFactory<CustomTNTEntity>) CustomTNTEntity::new, EntityClassification.MISC)
.build(BLOCK_ID));
static {
ITEMS.register(BLOCK_ID, () -> new BlockItem(CUSTOM_TNT.get(), new Item.Properties()));
}
public CustomTNTTest() {
IEventBus modBus = FMLJavaModLoadingContext.get().getModEventBus();
BLOCKS.register(modBus);
ITEMS.register(modBus);
ENTITIES.register(modBus);
}
public static class CustomTNTBlock extends TNTBlock {
public CustomTNTBlock(Properties properties) {
super(properties);
}
@Override
public void onExplosionDestroy(World world, BlockPos pos, Explosion explosion) {
if (!world.isRemote) {
TNTEntity tnt = new CustomTNTEntity(world, (float) pos.getX() + 0.5F, pos.getY(), (float) pos.getZ() + 0.5F, explosion.getExplosivePlacedBy());
tnt.setFuse((short) (world.rand.nextInt(tnt.getFuse() / 4) + tnt.getFuse() / 8));
world.addEntity(tnt);
}
}
@Override
public void catchFire(BlockState state, World world, BlockPos pos, @Nullable Direction face, @Nullable LivingEntity igniter) {
if (!world.isRemote) {
TNTEntity tnt = new CustomTNTEntity(world, pos.getX() + 0.5F, pos.getY(), pos.getZ() + 0.5F, igniter);
world.addEntity(tnt);
world.playSound(null, tnt.getPosX(), tnt.getPosY(), tnt.getPosZ(), SoundEvents.ENTITY_TNT_PRIMED, SoundCategory.BLOCKS, 1.0F, 1.0F);
}
}
}
/**
* Custom TNT Entity that has a fuse of a quarter length, and four times the explosion strength
*//*
public static class CustomTNTEntity extends TNTEntity {
public CustomTNTEntity(EntityType<CustomTNTEntity> type, World world) {
super(type, world);
setFuse(getFuse() / 4);
}
public CustomTNTEntity(World world, double x, double y, double z, @Nullable LivingEntity placer) {
super(world, x, y, z, placer);
setFuse(getFuse() / 4);
}
@Nonnull
@Override
public EntityType<?> getType() {
return CUSTOM_TNT_ENTITY.get();
}
@Override
protected void explode() {
this.world.createExplosion(this, this.getPosX(), this.getPosY(), this.getPosZ(), 16.0F, Explosion.Mode.BREAK);
}
@Nonnull
@Override
public IPacket<?> createSpawnPacket() {
return NetworkHooks.getEntitySpawningPacket(this);
}
}
}
*/

View File

@ -1,191 +0,0 @@
/*
* Minecraft Forge
* Copyright (c) 2016-2019.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation version 2.1
* of the License.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
/*
package net.minecraftforge.debug.block;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.material.Material;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.BlockItem;
import net.minecraft.item.Item;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.tileentity.TileEntityType;
import net.minecraft.util.Hand;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.BlockRayTraceResult;
import net.minecraft.util.text.StringTextComponent;
import net.minecraft.world.IBlockReader;
import net.minecraft.world.World;
import net.minecraftforge.common.FarmlandWaterManager;
import net.minecraftforge.common.ticket.AABBTicket;
import net.minecraftforge.event.RegistryEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.registries.ObjectHolder;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import java.util.Optional;
import javax.annotation.Nullable;
//This adds a block that creates a 4x4x4 watered region when activated
@Mod(FarmlandWaterTest.MOD_ID)
@Mod.EventBusSubscriber
public class FarmlandWaterTest
{
static final String MOD_ID = "farmland_water_test";
static final String BLOCK_ID = "test_block";
static final String TILE_ID = "test_tile";
private static Logger logger = LogManager.getLogger(FarmlandWaterTest.class);
@ObjectHolder(BLOCK_ID)
public static final Block test_block = null;
@ObjectHolder(TILE_ID)
public static final TileEntityType<TestTileEntity> test_tile = null;
@SubscribeEvent
public static void registerBlocks(RegistryEvent.Register<Block> event)
{
event.getRegistry().register(new TestBlock(Block.Properties.create(Material.ROCK)).setRegistryName(MOD_ID, BLOCK_ID));
}
@SubscribeEvent
public static void registerTileEntity(RegistryEvent.Register<TileEntityType<?>> event)
{
event.getRegistry().register(TileEntityType.Builder.func_223042_a(TestTileEntity::new, test_block).build(null).setRegistryName(MOD_ID, TILE_ID));
}
@SubscribeEvent
public static void registerItems(RegistryEvent.Register<Item> event)
{
event.getRegistry().register(new BlockItem(test_block, new Item.Properties()).setRegistryName(new ResourceLocation(MOD_ID, BLOCK_ID)));
}
public static class TestBlock extends Block
{
public TestBlock(Block.Properties props)
{
super(props);
}
@Override
public boolean hasTileEntity(BlockState state)
{
return true;
}
@Nullable
@Override
public TileEntity createTileEntity(BlockState state, IBlockReader world)
{
return new TestTileEntity();
}
@Override
public boolean onBlockActivated(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockRayTraceResult rayTrace)
{
Optional<TestTileEntity> opt = getTE(world, pos);
opt.ifPresent(tileEntity -> {
tileEntity.isActive = !tileEntity.isActive;
tileEntity.updateTicket();
player.sendStatusMessage(new StringTextComponent("Changed block powered state to " + tileEntity.isActive), true);
logger.info("Changed block powered state at {} to {}", pos, tileEntity.isActive);
});
return opt.isPresent();
}
@Override
public void onReplaced(BlockState state, World world, BlockPos pos, BlockState newState, boolean isMoving)
{
getTE(world, pos).ifPresent(TileEntity::remove);
}
private Optional<TestTileEntity> getTE(World world, BlockPos pos)
{
if (world.isRemote) return Optional.empty();
return Optional.ofNullable((TestTileEntity)world.getTileEntity(pos));
}
}
public static class TestTileEntity extends TileEntity
{
private AABBTicket farmlandTicket;
private boolean isActive = false;
public TestTileEntity()
{
super(FarmlandWaterTest.test_tile);
}
@Override
public void onLoad()
{
if (!world.isRemote)
{
farmlandTicket = FarmlandWaterManager.addAABBTicket(world, new AxisAlignedBB(pos).grow(4D));
updateTicket();
}
}
private void updateTicket()
{
if (world.isRemote)
return;
if (isActive)
farmlandTicket.validate();
else
farmlandTicket.invalidate();
}
@Override
public CompoundNBT write(CompoundNBT compound)
{
compound = super.write(compound);
compound.putBoolean("active", isActive);
return compound;
}
@Override
public void read(CompoundNBT compound)
{
super.read(compound);
isActive = compound.getBoolean("active");
}
@Override
public void remove()
{
if (!world.isRemote)
{
farmlandTicket.invalidate();
}
}
}
}
*/

View File

@ -1,122 +0,0 @@
/*
* Minecraft Forge
* Copyright (c) 2016-2019.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation version 2.1
* of the License.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
package net.minecraftforge.debug.block;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.model.ModelResourceLocation;
import net.minecraft.entity.Entity;
import net.minecraft.item.Item;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Vec3d;
import net.minecraft.world.World;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.client.event.ModelRegistryEvent;
import net.minecraftforge.client.model.ModelLoader;
import net.minecraftforge.event.RegistryEvent;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.Mod.EventBusSubscriber;
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
import net.minecraftforge.registries.ObjectHolder;
import net.minecraftforge.eventbus.api.SubscribeEvent;
//@Mod(MaterialFogColorTest.MODID)
//@Mod.EventBusSubscriber
public class MaterialFogColorTest
{
static final String MODID = "fog_color_in_material_test";
/*
static
{
FluidRegistry.enableUniversalBucket();
}
static int color = 0xFFd742f4; // <-- change value for testing
public static final Fluid SLIME = new Fluid("slime", new ResourceLocation(MODID, "slime_still"), new ResourceLocation(MODID, "slime_flow"), new ResourceLocation(MODID, "slime_overlay")) {
@Override
public int getColor()
{
return color;
}
};
//@ObjectHolder("slime")
//public static final BlockFluidBase SLIME_BLOCK = null;
@ObjectHolder("test_fluid")
public static final Block FLUID_BLOCK = null;
@ObjectHolder("test_fluid")
public static final Item FLUID_ITEM = null;
private static final ResourceLocation RES_LOC = new ResourceLocation(MODID, "slime");
private static final ResourceLocation testFluidRegistryName = new ResourceLocation(MODID, "test_fluid");
@SubscribeEvent
public void preInit(FMLCommonSetupEvent event)
{
FluidRegistry.registerFluid(SLIME);
FluidRegistry.addBucketForFluid(SLIME);
}
@SubscribeEvent
public static void registerBlocks(RegistryEvent.Register<Block> event)
{
event.getRegistry().register((new BlockFluidClassic(SLIME, Material.WATER)).setRegistryName(RES_LOC).setUnlocalizedName(RES_LOC.toString()));
Fluid fluid = new Fluid("fog_test", new ResourceLocation("blocks/water_still"), new ResourceLocation("blocks/water_flow"), new ResourceLocation("blocks/water_overlay"));
FluidRegistry.registerFluid(fluid);
Block fluidBlock = new BlockFluidClassic(fluid, Material.WATER)
{
@Override
public Vec3d getFogColor(World world, BlockPos pos, BlockState state, Entity entity, Vec3d originalColor, float partialTicks)
{
return new Vec3d(0.6F, 0.1F, 0.0F);
}
};
event.getRegistry().register(fluidBlock.setCreativeTab(CreativeTabs.BUILDING_BLOCKS).setUnlocalizedName(MODID + ".test_fluid").setRegistryName(testFluidRegistryName));
}
@net.minecraftforge.eventbus.api.SubscribeEvent
public static void registerItems(RegistryEvent.Register<Item> event)
{
event.getRegistry().register(new ItemBlock(FLUID_BLOCK).setRegistryName(testFluidRegistryName));
}
@EventBusSubscriber(value = Dist.CLIENT, modid = MODID)
public static class ClientEventHandler
{
@SubscribeEvent
public static void registerModels(ModelRegistryEvent event)
{
ModelResourceLocation fluidLocation = new ModelResourceLocation(testFluidRegistryName, "fluid");
ModelLoader.registerItemVariants(FLUID_ITEM);
ModelLoader.setCustomMeshDefinition(FLUID_ITEM, stack -> fluidLocation);
ModelLoader.setCustomStateMapper(FLUID_BLOCK, new StateMapperBase() {
@Override
protected ModelResourceLocation getModelResourceLocation(BlockState state)
{
return fluidLocation;
}
});
}
}
*/
}

View File

@ -1,141 +0,0 @@
/*
* Minecraft Forge
* Copyright (c) 2016-2019.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation version 2.1
* of the License.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
/*
package net.minecraftforge.debug.block;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.material.Material;
import net.minecraft.client.particle.ParticleManager;
import net.minecraft.entity.Entity;
import net.minecraft.entity.LivingEntity;
import net.minecraft.item.BlockItem;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.particles.ParticleTypes;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.RayTraceResult;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.StringTextComponent;
import net.minecraft.world.ServerWorld;
import net.minecraft.world.World;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.event.RegistryEvent;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.registries.ObjectHolder;
import net.minecraftforge.eventbus.api.SubscribeEvent;
@Mod(ParticleEffectsTest.MOD_ID)
@Mod.EventBusSubscriber
public class ParticleEffectsTest
{
public static final String MOD_ID = "block_particle_effects_test";
public static final String BLOCK_ID = "particle_block";
@ObjectHolder(BLOCK_ID)
public static final Block PARTICLE_BLOCK = null;
@ObjectHolder(BLOCK_ID)
public static final Item PARTICLE_ITEM = null;
private static final ResourceLocation particleBlockLocation = new ResourceLocation(MOD_ID, "particle_block");
@SubscribeEvent
public static void registerBlocks(RegistryEvent.Register<Block> event)
{
Block block = new Block(Block.Properties.create(Material.ROCK).hardnessAndResistance(20, 0))
{
@Override
public boolean addLandingEffects(BlockState state, ServerWorld world, BlockPos blockPosition, BlockState BlockState, LivingEntity entity, int numberOfParticles)
{
world.spawnParticle(ParticleTypes.EXPLOSION, entity.posX, entity.posY, entity.posZ, numberOfParticles, 0, 0, 0, 0.1D);
return true;
}
@Override
public boolean addRunningEffects(BlockState state, World world, BlockPos pos, Entity entity)
{
world.addParticle(ParticleTypes.EXPLOSION, entity.posX, entity.posY, entity.posZ, 1, 0, 0);
return true;
}
@Override
@OnlyIn(Dist.CLIENT)
public boolean addHitEffects(BlockState state, World world, RayTraceResult target, ParticleManager manager)
{
world.addParticle(ParticleTypes.EXPLOSION, target.getHitVec().x, target.getHitVec().y, target.getHitVec().z, 0, 1, 0);
return true;
}
@Override
@OnlyIn(Dist.CLIENT)
public boolean addDestroyEffects(BlockState state, World world, BlockPos pos, ParticleManager manager)
{
world.addParticle(ParticleTypes.EXPLOSION, pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5, 0, 0, 1);
return true;
}
};
event.getRegistry().register(block.setRegistryName(particleBlockLocation));
}
@SubscribeEvent
public static void registerItems(RegistryEvent.Register<Item> event)
{
Item item = new BlockItem(PARTICLE_BLOCK, new Item.Properties()) {
@Override
public ITextComponent getDisplayName(ItemStack stack)
{
return new StringTextComponent("Particle Tests Block");
}
};
event.getRegistry().register(item.setRegistryName(particleBlockLocation));
}
*/
/*
@EventBusSubscriber(value = Dist.CLIENT, modid = MOD_ID)
public static class ClientEventHandler
{
@SubscribeEvent
public static void registerModels(ModelRegistryEvent event)
{
ModelResourceLocation normalLoc = new ModelResourceLocation("minecraft:stone", "normal");
ModelResourceLocation invLoc = new ModelResourceLocation("minecraft:stone", "normal");
ModelLoader.setCustomStateMapper(PARTICLE_BLOCK, new StateMapperBase()
{
@Override
protected ModelResourceLocation getModelResourceLocation(BlockState state)
{
return normalLoc;
}
});
ModelLoader.setCustomModelResourceLocation(PARTICLE_ITEM, 0, invLoc);
}
}
*//*
}
*/

View File

@ -1,72 +0,0 @@
/*
* Minecraft Forge
* Copyright (c) 2016-2019.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation version 2.1
* of the License.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
package net.minecraftforge.debug.block;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.material.Material;
import net.minecraft.pathfinding.PathNodeType;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockReader;
import net.minecraftforge.event.RegistryEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.registries.ObjectHolder;
@Mod(PathNodeTypeTest.MOD_ID)
@Mod.EventBusSubscriber
public class PathNodeTypeTest
{
static final String MOD_ID = "ai_node_type_test";
static final String BLOCK_ID = "test_block";
@ObjectHolder(BLOCK_ID)
private static Block TEST_BLOCK = null;
/*TODO
@SubscribeEvent
public static void register(RegistryEvent.Register<Block> event)
{
event.getRegistry().register((new Block(Block.Properties.create(Material.ROCK))
{
@Override
public PathNodeType getAiPathNodeType(BlockState state, IBlockReader world, BlockPos pos)
{
return PathNodeType.DOOR_OPEN;
}
}).setRegistryName(MOD_ID, BLOCK_ID));
}
@Mod.EventBusSubscriber(value = Dist.CLIENT, modid = MOD_ID)
public static class ClientEventHandler
{
@SubscribeEvent
public static void registerModels(ModelRegistryEvent event)
{
if (ENABLED)
{
ModelLoader.setCustomStateMapper(TEST_BLOCK, block -> Collections.emptyMap());
ModelBakery.registerItemVariants(Item.getItemFromBlock(TEST_BLOCK));
}
}
}
*/
}

View File

@ -1,44 +0,0 @@
/*
* Minecraft Forge
* Copyright (c) 2016-2019.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation version 2.1
* of the License.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
/*
package net.minecraftforge.debug.block;
import net.minecraft.world.IWorld;
import net.minecraft.world.biome.Biomes;
import net.minecraft.world.dimension.DimensionType;
import net.minecraftforge.event.world.BlockEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.Mod;
@Mod("portal_spawn_event_test")
@Mod.EventBusSubscriber
public class PortalSpawnEventTest
{
@SubscribeEvent
public static void onTrySpawnPortal(BlockEvent.PortalSpawnEvent event)
{
IWorld world = event.getWorld();
if (world.getWorld().getDimension().getType() == DimensionType.OVERWORLD && world.getBiome(event.getPos()) != Biomes.field_222371_ax)
event.setCanceled(true);
}
}
*/

View File

@ -1,90 +0,0 @@
/*
* Minecraft Forge
* Copyright (c) 2016-2019.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation version 2.1
* of the License.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
package net.minecraftforge.debug.chat;
import net.minecraft.command.CommandException;
import net.minecraft.server.MinecraftServer;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.text.StringTextComponent;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.registries.ForgeRegistries;
import net.minecraftforge.registries.GameData;
import javax.annotation.Nullable;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
//@Mod("client_command_test")
public class ClientCommandTest
{
/*
@EventHandler
public void init(FMLInitializationEvent event)
{
ClientCommandHandler.instance.registerCommand(new TestCommand());
}
private class TestCommand extends CommandBase
{
@Override
public String getName()
{
return "clientCommandTest";
}
@Override
public String getUsage(ICommandSender sender)
{
return "clientCommandTest <block>";
}
@Override
public boolean checkPermission(MinecraftServer server, ICommandSender sender)
{
return true;
}
@Override
public List<String> getTabCompletions(MinecraftServer server, ICommandSender sender, String[] args, @Nullable BlockPos pos)
{
if (args.length > 0)
{
return getListOfStringsMatchingLastWord(args, ForgeRegistries.BLOCKS.getKeys());
}
return Collections.emptyList();
}
@Override
public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException
{
if (args.length > 0)
{
sender.sendMessage(new StringTextComponent("Input: " + Arrays.toString(args)));
}
else
{
sender.sendMessage(new StringTextComponent("No arguments."));
}
}
}
*/
}

View File

@ -1,132 +0,0 @@
/*
* Minecraft Forge
* Copyright (c) 2016-2019.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation version 2.1
* of the License.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
/*
package net.minecraftforge.debug.client;
import com.google.common.collect.ImmutableList;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.client.renderer.texture.TextureMap;
import net.minecraft.client.resources.IResourceManager;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.client.event.TextureStitchEvent;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.RegistryEvent;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.event.FMLPreInitializationEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import org.apache.logging.log4j.Logger;
import javax.annotation.Nonnull;
import java.util.Collection;
import java.util.function.Function;
*/
/**
* Test for {@link TextureStitchEvent.Pre}.
*//*
//@Mod(modid = CustomTextureAtlasSpriteTest.MOD_ID, name = CustomTextureAtlasSpriteTest.NAME, version = "1.0", clientSideOnly = true)
public class CustomTextureAtlasSpriteTest
{
static final String MOD_ID = "custom_sprite_test";
static final String NAME = "Custom sprite test";
private static Logger logger;
//@Mod.EventBusSubscriber(modid = MOD_ID)
public static class Registration
{
@net.minecraftforge.eventbus.api.SubscribeEvent
public static void registerBlocks(RegistryEvent.Register<Block> event)
{
event.getRegistry().register(new Block(Material.WOOD).setRegistryName(MOD_ID, "custom_sprite_block").setCreativeTab(CreativeTabs.MISC));
}
}
@Mod.EventHandler
public void preInit(FMLPreInitializationEvent event)
{
logger = event.getModLog();
MinecraftForge.EVENT_BUS.register(this);
}
@net.minecraftforge.eventbus.api.SubscribeEvent
public void textureStitch(TextureStitchEvent.Pre event)
{
DelegateSprite bottom = DelegateSprite.make("bottom", new ResourceLocation("blocks/diamond_block"));
DelegateSprite top = DelegateSprite.make("top", new ResourceLocation("blocks/tnt_side"));
TextureMap textureMap = event.getMap();
textureMap.setTextureEntry(bottom);
textureMap.setTextureEntry(top);
}
static final class DelegateSprite extends TextureAtlasSprite
{
final ResourceLocation delegate;
private DelegateSprite(ResourceLocation loc, ResourceLocation delegate)
{
super(loc.toString());
this.delegate = delegate;
}
static DelegateSprite make(String name, ResourceLocation delegate)
{
return new DelegateSprite(new ResourceLocation(MOD_ID, name), delegate);
}
@Override
public boolean hasCustomLoader(@Nonnull IResourceManager manager, @Nonnull ResourceLocation location)
{
return true;
}
@Override
public Collection<ResourceLocation> getDependencies()
{
return ImmutableList.of(delegate);
}
@Override
public boolean load(@Nonnull IResourceManager manager, @Nonnull ResourceLocation location, @Nonnull Function<ResourceLocation, TextureAtlasSprite> textureGetter)
{
final TextureAtlasSprite sprite = textureGetter.apply(delegate);
width = sprite.getIconWidth();
height = sprite.getIconHeight();
final int[][] oldPixels = sprite.getFrameTextureData(0);
final int[][] pixels = new int[Minecraft.getMinecraft().gameSettings.mipmapLevels + 1][];
pixels[0] = new int[width * height];
for (int p = 0; p < width * height; p++) {
pixels[0][p] = oldPixels[0][p] >> 8;
}
this.clearFramesTextureData();
this.framesTextureData.add(pixels);
return false;
}
}
}
*/

View File

@ -1,61 +0,0 @@
/*
* Minecraft Forge
* Copyright (c) 2016-2019.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation version 2.1
* of the License.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
/*
package net.minecraftforge.debug.client;
import net.minecraft.block.material.Material;
import net.minecraftforge.client.event.EntityViewRenderEvent;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.Mod.EventHandler;
import net.minecraftforge.fml.event.FMLInitializationEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
*/
/**
* Simple mod to test fov modifier.
*//*
//@Mod(modid = "fovmodifiertest", name = "FOV Modifier Test", version = "0.0.0", clientSideOnly = true)
public class FOVModifierEventTest
{
static final boolean ENABLED = false;
@EventHandler
public void init(FMLInitializationEvent event)
{
if (ENABLED)
{
MinecraftForge.EVENT_BUS.register(this);
}
}
@SubscribeEvent
public void getFOVModifier(EntityViewRenderEvent.FOVModifier event)
{
if (event.getState().getMaterial() == Material.WATER)
{
event.setFOV(event.getFOV() / 60.0f * 50.0f);
}
}
}
*/

View File

@ -1,66 +0,0 @@
/*
* Minecraft Forge
* Copyright (c) 2016-2019.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation version 2.1
* of the License.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
/*
package net.minecraftforge.debug.client;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.ItemStack;
import net.minecraft.util.NonNullList;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.api.distmarker.Dist;
//@Mod(modid = SearchableCreativeTabTest.MODID, name = "Debug Search Tab", version = "1.0", acceptableRemoteVersions = "*")
public class SearchableCreativeTabTest
{
public static final String MODID = "debugsearchtab";
static final boolean ENABLED = false;
public static final CreativeTabs SEARCH_TAB = !ENABLED ? null : new CreativeTabs(1, "searchtab")
{
@OnlyIn(Dist.CLIENT)
public ItemStack getTabIconItem()
{
return new ItemStack(Items.TOTEM_OF_UNDYING);
}
@Override
public boolean hasSearchBar()
{
return true;
}
@Override
@OnlyIn(Dist.CLIENT)
public void displayAllRelevantItems(NonNullList<ItemStack> items)
{
super.displayAllRelevantItems(items);
items.add(new ItemStack(Blocks.BARRIER));
items.add(new ItemStack(Blocks.COMMAND_BLOCK));
items.add(new ItemStack(Blocks.CHAIN_COMMAND_BLOCK));
items.add(new ItemStack(Blocks.REPEATING_COMMAND_BLOCK));
}
};
}
*/

View File

@ -1,64 +0,0 @@
/*
* Minecraft Forge
* Copyright (c) 2016-2019.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation version 2.1
* of the License.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
/*
package net.minecraftforge.debug.client.gui;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.inventory.Slot;
import net.minecraft.item.Item;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.client.event.GuiContainerEvent;
import net.minecraftforge.fml.client.config.GuiUtils;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.Mod.EventBusSubscriber;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.registry.GameRegistry.ObjectHolder;
//@EventBusSubscriber(Side.CLIENT)
//@Mod(modid = "guicontainereventtest", name = "GuiContainer Event Tests!", version = "1.0", acceptableRemoteVersions = "*")
public class ContainerDrawForegroundEventTest
{
static final boolean ENABLED = false;
@ObjectHolder("minecraft:stone")
public static final Item STONE_ITEM = null;
@SubscribeEvent
public static void onForegroundRender(GuiContainerEvent.DrawForeground event)
{
if (!ENABLED) return;
for (Slot slot : event.getGuiContainer().inventorySlots.inventorySlots)
{
if (slot.getStack().getItem() == STONE_ITEM)
{
GlStateManager.disableLighting();
GuiUtils.drawGradientRect(400, slot.xPos, slot.yPos, slot.xPos + 16, slot.yPos + 16, 0x80000000, 0x80000000);
GlStateManager.enableLighting();
}
}
}
}
*/

View File

@ -1,59 +0,0 @@
/*
* Minecraft Forge
* Copyright (c) 2016-2019.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation version 2.1
* of the License.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
/*
package net.minecraftforge.debug.client.gui;
import net.minecraft.init.Items;
import net.minecraftforge.client.event.RenderTooltipEvent;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
//@Mod(modid = TooltipColorEventTest.MODID, name = "Tooltip Color Test", version = "0.1", clientSideOnly = true)
public class TooltipColorEventTest
{
public static final String MODID = "tooltipcolortest";
private static final boolean ENABLE = false;
public TooltipColorEventTest()
{
if (ENABLE)
{
MinecraftForge.EVENT_BUS.register(this);
}
}
@SubscribeEvent
@SideOnly(Side.CLIENT)
public void getTooltipColor(RenderTooltipEvent.Color event)
{
if (event.getStack().getItem() == Items.APPLE)
{
event.setBackground(0xF0510404);
event.setBorderStart(0xF0bc0909);
event.setBorderEnd(0xF03f0f0f);
}
}
}*/

View File

@ -1,579 +0,0 @@
/*
* Minecraft Forge
* Copyright (c) 2016-2019.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation version 2.1
* of the License.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
/*
package net.minecraftforge.debug.client.model;
import com.google.common.collect.ImmutableMap;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.block.properties.IProperty;
import net.minecraft.block.properties.PropertyDirection;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.model.ModelResourceLocation;
import net.minecraft.client.renderer.entity.Render;
import net.minecraft.client.renderer.entity.RenderLiving;
import net.minecraft.client.renderer.entity.RenderManager;
import net.minecraft.client.renderer.texture.TextureMap;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.EntityLiving;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.SharedMonsterAttributes;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.*;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.client.event.ModelRegistryEvent;
import net.minecraftforge.client.model.ModelLoader;
import net.minecraftforge.client.model.ModelLoaderRegistry;
import net.minecraftforge.client.model.animation.Animation;
import net.minecraftforge.client.model.animation.AnimationTESR;
import net.minecraftforge.client.model.b3d.B3DLoader;
import net.minecraftforge.client.model.pipeline.VertexLighterSmoothAo;
import net.minecraftforge.common.animation.Event;
import net.minecraftforge.common.animation.ITimeValue;
import net.minecraftforge.common.animation.TimeValues.VariableValue;
import net.minecraftforge.common.capabilities.Capability;
import net.minecraftforge.common.capabilities.ICapabilityProvider;
import net.minecraftforge.common.model.animation.CapabilityAnimation;
import net.minecraftforge.common.model.animation.IAnimationStateMachine;
import net.minecraftforge.common.property.ExtendedBlockState;
import net.minecraftforge.common.property.IUnlistedProperty;
import net.minecraftforge.common.property.Properties;
import net.minecraftforge.event.RegistryEvent;
import net.minecraftforge.fml.client.registry.ClientRegistry;
import net.minecraftforge.fml.client.registry.IRenderFactory;
import net.minecraftforge.fml.client.registry.RenderingRegistry;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.Mod.EventHandler;
import net.minecraftforge.fml.common.Mod.Instance;
import net.minecraftforge.fml.event.FMLPreInitializationEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.registry.EntityRegistry;
import net.minecraftforge.fml.common.registry.GameRegistry;
import net.minecraftforge.fml.common.registry.GameRegistry.ObjectHolder;
import org.apache.logging.log4j.Logger;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
//@Mod(modid = AnimatedModelTest.MODID, name = "ForgeDebugModelAnimation", version = AnimatedModelTest.VERSION, acceptableRemoteVersions = "*")
public class AnimatedModelTest
{
public static final String MODID = "forgedebugmodelanimation";
public static final String VERSION = "0.0";
public static final String blockName = "test_animation_block";
public static final PropertyDirection FACING = PropertyDirection.create("facing");
@ObjectHolder(blockName)
public static final Block TEST_BLOCK = null;
@ObjectHolder(blockName)
public static final Item TEST_ITEM = null;
public static final String rotateBlockName = "rotatest";
@ObjectHolder(rotateBlockName)
public static final Block TEST_ROTATE_BLOCK = null;
@ObjectHolder(rotateBlockName)
public static final Item TEST_ROTATE_ITEM = null;
@Instance(MODID)
public static AnimatedModelTest instance;
public static CommonProxy proxy;
private static Logger logger;
//@Mod.EventBusSubscriber(modid = MODID)
public static class Registration
{
@net.minecraftforge.eventbus.api.SubscribeEvent
public static void registerBlocks(RegistryEvent.Register<Block> event)
{
GameRegistry.registerTileEntity(Chest.class, MODID + ":" + "tile_" + blockName);
GameRegistry.registerTileEntity(Spin.class, MODID + ":" + "tile_" + rotateBlockName);
event.getRegistry().register(
new Block(Material.WOOD)
{
{
setCreativeTab(CreativeTabs.BUILDING_BLOCKS);
setUnlocalizedName(MODID + "." + blockName);
setRegistryName(new ResourceLocation(MODID, blockName));
}
@Override
public ExtendedBlockState createBlockState()
{
return new ExtendedBlockState(this, new IProperty[]{FACING, Properties.StaticProperty}, new IUnlistedProperty[]{Properties.AnimationProperty});
}
@Override
public boolean isOpaqueCube(IBlockState state)
{
return false;
}
@Override
public boolean isFullCube(IBlockState state)
{
return false;
}
@Override
public IBlockState getStateForPlacement(World world, BlockPos pos, EnumFacing facing, float hitX, float hitY, float hitZ, int meta, EntityLivingBase placer)
{
return this.getDefaultState().withProperty(FACING, EnumFacing.getDirectionFromEntityLiving(pos, placer));
}
@Override
public IBlockState getStateFromMeta(int meta)
{
return getDefaultState().withProperty(FACING, EnumFacing.getFront(meta));
}
@Override
public int getMetaFromState(IBlockState state)
{
return state.getValue(FACING).getIndex();
}
@Override
public boolean hasTileEntity(IBlockState state)
{
return true;
}
@Override
public TileEntity createTileEntity(World world, IBlockState state)
{
return new Chest();
}
@Override
public IBlockState getActualState(IBlockState state, IBlockAccess world, BlockPos pos)
{
return state.withProperty(Properties.StaticProperty, true);
}
*/
/*@Override
public IBlockState getExtendedState(IBlockState state, IBlockAccess world, BlockPos pos) {
TileEntity te = world.getTileEntity(pos);
if(te instanceof Chest && state instanceof IExtendedBlockState)
{
return ((Chest)te).getState((IExtendedBlockState)state);
}
return super.getExtendedState(state, world, pos);
}*//*
@Override
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ)
{
if (world.isRemote)
{
TileEntity te = world.getTileEntity(pos);
if (te instanceof Chest)
{
((Chest) te).click(player.isSneaking());
}
}
return true;
}
});
event.getRegistry().register(new Block(Material.WOOD){
{
setCreativeTab(CreativeTabs.BUILDING_BLOCKS);
setUnlocalizedName(MODID + "." + rotateBlockName);
setRegistryName(new ResourceLocation(MODID, rotateBlockName));
}
@Override
public ExtendedBlockState createBlockState()
{
return new ExtendedBlockState(this, new IProperty[]{ Properties.StaticProperty }, new IUnlistedProperty[]{ Properties.AnimationProperty });
}
@Override
public boolean isOpaqueCube(IBlockState state) { return false; }
@Override
public boolean isFullCube(IBlockState state) { return false; }
@Override
public boolean hasTileEntity(IBlockState state) {
return true;
}
@Override
public IBlockState getActualState(IBlockState state, IBlockAccess world, BlockPos pos) {
return state.withProperty(Properties.StaticProperty, false);
}
@Override
public int getMetaFromState(IBlockState state) {
return 0;
}
@Override
public EnumBlockRenderType getRenderType(IBlockState state) {
return EnumBlockRenderType.ENTITYBLOCK_ANIMATED;
}
@Override
public IBlockState getStateFromMeta(int meta) {
return getDefaultState();
}
@Override
public TileEntity createTileEntity(World world, IBlockState state) {
return new Spin();
}
});
}
@net.minecraftforge.eventbus.api.SubscribeEvent
public static void registerItems(RegistryEvent.Register<Item> event)
{
event.getRegistry().register(
new ItemBlock(TEST_BLOCK)
{
@Override
public ICapabilityProvider initCapabilities(ItemStack stack, @Nullable NBTTagCompound nbt)
{
return new ItemAnimationHolder();
}
}.setRegistryName(TEST_BLOCK.getRegistryName())
);
event.getRegistry().register(
new ItemBlock(TEST_ROTATE_BLOCK) {
}.setRegistryName(TEST_ROTATE_BLOCK.getRegistryName())
);
}
}
public static abstract class CommonProxy
{
@Nullable
public IAnimationStateMachine load(ResourceLocation location, ImmutableMap<String, ITimeValue> parameters){ return null; };
}
public static class ServerProxy extends CommonProxy {}
//@Mod.EventBusSubscriber(value = Side.CLIENT, modid = MODID)
public static class ClientProxy extends CommonProxy
{
public IAnimationStateMachine load(ResourceLocation location, ImmutableMap<String, ITimeValue> parameters)
{
return ModelLoaderRegistry.loadASM(location, parameters);
}
@SubscribeEvent
public static void registerModels(ModelRegistryEvent event)
{
B3DLoader.INSTANCE.addDomain(MODID);
ModelLoader.setCustomModelResourceLocation(TEST_ITEM, 0, new ModelResourceLocation(TEST_ITEM.getRegistryName(), "inventory"));
ClientRegistry.bindTileEntitySpecialRenderer(Chest.class, new AnimationTESR<Chest>()
{
@Override
public void handleEvents(Chest chest, float time, Iterable<Event> pastEvents)
{
chest.handleEvents(time, pastEvents);
}
});
ModelLoader.setCustomModelResourceLocation(TEST_ROTATE_ITEM, 0, new ModelResourceLocation(TEST_ROTATE_ITEM.getRegistryName(), "inventory"));
ClientRegistry.bindTileEntitySpecialRenderer(Spin.class, new AnimationTESR<Spin>());
String entityName = MODID + ":entity_chest";
//EntityRegistry.registerGlobalEntityID(EntityChest.class, entityName, EntityRegistry.findGlobalUniqueEntityId());
EntityRegistry.registerModEntity(new ResourceLocation(entityName), EntityChest.class, entityName, 0, AnimatedModelTest.instance, 64, 20, true, 0xFFAAAA00, 0xFFDDDD00);
RenderingRegistry.registerEntityRenderingHandler(EntityChest.class, new IRenderFactory<EntityChest>()
{
@SuppressWarnings("deprecation")
public Render<EntityChest> createRenderFor(RenderManager manager)
{
*/
/*model = ModelLoaderRegistry.getModel(new ResourceLocation(ModelLoaderRegistryTest.MODID, "block/chest.b3d"));
if(model instanceof IRetexturableModel)
{
model = ((IRetexturableModel)model).retexture(ImmutableMap.of("#chest", "entity/chest/normal"));
}
if(model instanceof IModelCustomData)
{
model = ((IModelCustomData)model).process(ImmutableMap.of("mesh", "[\"Base\", \"Lid\"]"));
}*//*
ResourceLocation location = new ModelResourceLocation(new ResourceLocation(MODID, blockName), "entity");
return new RenderLiving<EntityChest>(manager, new net.minecraftforge.client.model.animation.AnimationModelBase<EntityChest>(location, new VertexLighterSmoothAo(Minecraft.getMinecraft().getBlockColors()))
{
@Override
public void handleEvents(EntityChest chest, float time, Iterable<Event> pastEvents)
{
chest.handleEvents(time, pastEvents);
}
}, 0.5f)
{
protected ResourceLocation getEntityTexture(EntityChest entity)
{
return TextureMap.LOCATION_BLOCKS_TEXTURE;
}
};
}
});
}
}
private static class ItemAnimationHolder implements ICapabilityProvider
{
private final VariableValue cycleLength = new VariableValue(4);
private final IAnimationStateMachine asm = proxy.load(new ResourceLocation(MODID.toLowerCase(), "asms/block/engine.json"), ImmutableMap.<String, ITimeValue>of(
"cycle_length", cycleLength
));
@Override
public boolean hasCapability(@Nonnull Capability<?> capability, @Nullable EnumFacing facing)
{
return capability == CapabilityAnimation.ANIMATION_CAPABILITY;
}
@Override
@Nullable
public <T> T getCapability(@Nonnull Capability<T> capability, @Nullable EnumFacing facing)
{
if (capability == CapabilityAnimation.ANIMATION_CAPABILITY)
{
return CapabilityAnimation.ANIMATION_CAPABILITY.cast(asm);
}
return null;
}
}
@EventHandler
public void preInit(FMLPreInitializationEvent event)
{
logger = event.getModLog();
}
public static class Spin extends TileEntity
{
@Nullable
private final IAnimationStateMachine asm;
public Spin()
{
asm = proxy.load(new ResourceLocation(MODID, "asms/block/rotatest.json"), ImmutableMap.of());
}
@Override
public boolean hasCapability(@Nonnull Capability<?> capability, @Nullable EnumFacing side)
{
return capability == CapabilityAnimation.ANIMATION_CAPABILITY || super.hasCapability(capability, side);
}
@Override
@Nullable
public <T> T getCapability(@Nonnull Capability<T> capability, @Nullable EnumFacing side)
{
if (capability == CapabilityAnimation.ANIMATION_CAPABILITY)
{
return CapabilityAnimation.ANIMATION_CAPABILITY.cast(asm);
}
return super.getCapability(capability, side);
}
@Override
public boolean hasFastRenderer()
{
return true;
}
}
public static class Chest extends TileEntity
{
@Nullable
private final IAnimationStateMachine asm;
private final VariableValue cycleLength = new VariableValue(4);
private final VariableValue clickTime = new VariableValue(Float.NEGATIVE_INFINITY);
//private final VariableValue offset = new VariableValue(0);
public Chest()
{
*/
/*asm = proxy.load(new ResourceLocation(MODID.toLowerCase(), "asms/block/chest.json"), ImmutableMap.<String, ITimeValue>of(
"click_time", clickTime
));*//*
asm = proxy.load(new ResourceLocation(MODID.toLowerCase(), "asms/block/engine.json"), ImmutableMap.<String, ITimeValue>of(
"cycle_length", cycleLength,
"click_time", clickTime
//"offset", offset
));
}
public void handleEvents(float time, Iterable<Event> pastEvents)
{
for (Event event : pastEvents)
{
logger.info("Event: {} {} {} {}", event.event(), event.offset(), getPos(), time);
}
}
@Override
public boolean hasFastRenderer()
{
return true;
}
*/
/*public IExtendedBlockState getState(IExtendedBlockState state) {
return state.withProperty(B3DFrameProperty.instance, curState);
}*//*
public void click(boolean sneaking)
{
if (asm != null)
{
if (sneaking)
{
cycleLength.setValue(6 - cycleLength.apply(0));
}
*/
/*else if(asm.currentState().equals("closed"))
{
clickTime.setValue(Animation.getWorldTime(getWorld()));
asm.transition("opening");
}
else if(asm.currentState().equals("open"))
{
clickTime.setValue(Animation.getWorldTime(getWorld()));
asm.transition("closing");
}*//*
else if (asm.currentState().equals("default"))
{
float time = Animation.getWorldTime(getWorld(), Animation.getPartialTickTime());
clickTime.setValue(time);
//offset.setValue(time);
//asm.transition("moving");
asm.transition("starting");
}
else if (asm.currentState().equals("moving"))
{
clickTime.setValue(Animation.getWorldTime(getWorld(), Animation.getPartialTickTime()));
asm.transition("stopping");
}
}
}
@Override
public boolean hasCapability(@Nonnull Capability<?> capability, @Nullable EnumFacing side)
{
if (capability == CapabilityAnimation.ANIMATION_CAPABILITY)
{
return true;
}
return super.hasCapability(capability, side);
}
@Override
@Nullable
public <T> T getCapability(@Nonnull Capability<T> capability, @Nullable EnumFacing side)
{
if (capability == CapabilityAnimation.ANIMATION_CAPABILITY)
{
return CapabilityAnimation.ANIMATION_CAPABILITY.cast(asm);
}
return super.getCapability(capability, side);
}
}
public static class EntityChest extends EntityLiving
{
private final IAnimationStateMachine asm;
private final VariableValue cycleLength = new VariableValue(getHealth() / 5);
public EntityChest(World world)
{
super(world);
setSize(1, 1);
asm = proxy.load(new ResourceLocation(MODID.toLowerCase(), "asms/block/engine.json"), ImmutableMap.<String, ITimeValue>of(
"cycle_length", cycleLength
));
}
public void handleEvents(float time, Iterable<Event> pastEvents)
{
}
@Override
public void onEntityUpdate()
{
super.onEntityUpdate();
if (world.isRemote && cycleLength != null)
{
cycleLength.setValue(getHealth() / 5);
}
}
@Override
protected void applyEntityAttributes()
{
super.applyEntityAttributes();
this.getEntityAttribute(SharedMonsterAttributes.MAX_HEALTH).setBaseValue(60);
}
@Override
public boolean hasCapability(@Nonnull Capability<?> capability, @Nullable EnumFacing side)
{
if (capability == CapabilityAnimation.ANIMATION_CAPABILITY)
{
return true;
}
return super.hasCapability(capability, side);
}
@Override
@Nullable
public <T> T getCapability(@Nonnull Capability<T> capability, @Nullable EnumFacing side)
{
if (capability == CapabilityAnimation.ANIMATION_CAPABILITY)
{
return CapabilityAnimation.ANIMATION_CAPABILITY.cast(asm);
}
return super.getCapability(capability, side);
}
}
}
*/

View File

@ -1,124 +0,0 @@
/*
* Minecraft Forge
* Copyright (c) 2016-2019.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation version 2.1
* of the License.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
/*
package net.minecraftforge.debug.client.model;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.renderer.model.ModelResourceLocation;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.EntityEquipmentSlot;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.ResourceLocation;
import net.minecraft.world.World;
import net.minecraftforge.client.event.ModelRegistryEvent;
import net.minecraftforge.client.model.ModelLoader;
import net.minecraftforge.event.RegistryEvent;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.registry.GameRegistry.ObjectHolder;
import javax.annotation.Nullable;
import java.util.Random;
//@Mod(modid = ItemLayerModelTest.MODID, name = "ForgeDebugItemLayerModel", version = ItemLayerModelTest.VERSION, acceptableRemoteVersions = "*")
public class ItemLayerModelTest
{
public static final String MODID = "forgedebugitemlayermodel";
public static final String VERSION = "1.0";
@ObjectHolder("test_item")
public static final Item TEST_ITEM = null;
//@Mod.EventBusSubscriber(modid = MODID)
public static class Registration
{
@SubscribeEvent
public static void registrItems(RegistryEvent.Register<Item> event)
{
event.getRegistry().register(new TestItem());
}
@net.minecraftforge.eventbus.api.SubscribeEvent
public static void registerModels(ModelRegistryEvent event)
{
ModelLoader.setCustomModelResourceLocation(TEST_ITEM, 0, new ModelResourceLocation(MODID.toLowerCase() + ":" + TestItem.name, "inventory"));
}
}
public static final class TestItem extends Item
{
public static final String name = "test_item";
private TestItem()
{
setCreativeTab(CreativeTabs.BUILDING_BLOCKS);
setUnlocalizedName(MODID + ":" + name);
setRegistryName(new ResourceLocation(MODID, name));
}
@Override
public void onUpdate(ItemStack stack, World worldIn, Entity entityIn, int itemSlot, boolean isSelected)
{
NBTTagCompound tag = new NBTTagCompound();
tag.setInteger("foo", new Random().nextInt());
stack.setTagCompound(tag);
stack.setStackDisplayName(String.valueOf(new Random().nextInt()));
}
@Override
public boolean shouldCauseBlockBreakReset(ItemStack oldStack, ItemStack newStack)
{
return shouldCauseReequipAnimation(oldStack, newStack, false);
}
@Override
public boolean shouldCauseReequipAnimation(ItemStack oldStack, ItemStack newStack, boolean slotChanged)
{
oldStack = oldStack.copy();
oldStack.setTagCompound(null);
newStack = newStack.copy();
newStack.setTagCompound(null);
return !ItemStack.areItemStacksEqual(oldStack, newStack);
}
@Override
public int getHarvestLevel(ItemStack stack, String toolClass, @Nullable EntityPlayer player, @Nullable IBlockState blockState)
{
// This tool is a super pickaxe if the player is wearing a helment
if ("pickaxe".equals(toolClass) && player != null && !player.getItemStackFromSlot(EntityEquipmentSlot.HEAD).isEmpty())
{
return 5;
}
return super.getHarvestLevel(stack, toolClass, player, blockState);
}
@Override
public float getDestroySpeed(ItemStack stack, IBlockState state)
{
return 10f;
}
}
}
*/

View File

@ -1,86 +0,0 @@
/*
* Minecraft Forge
* Copyright (c) 2016-2019.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation version 2.1
* of the License.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
/*
package net.minecraftforge.debug.client.model;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.model.ModelResourceLocation;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.Item;
import net.minecraft.item.ItemBlock;
import net.minecraftforge.client.event.ModelRegistryEvent;
import net.minecraftforge.client.model.ModelLoader;
import net.minecraftforge.event.RegistryEvent;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.common.registry.GameRegistry;
import net.minecraftforge.fml.relauncher.Side;
//@Mod.EventBusSubscriber
//@Mod(modid = ItemModelConflictTest.MODID, name = "Test mod for model conflicts", version = "1.0", acceptableRemoteVersions = "*")
public class ItemModelConflictTest
{
public static final String MODID = "item_model_conflict_test";
@GameRegistry.ObjectHolder(MODID + ":item")
public static final Item TEST_ITEM = null;
@GameRegistry.ObjectHolder(MODID + ":test")
public static final Block TEST_BLOCK = null;
@SubscribeEvent
public static void registerBlocks(RegistryEvent.Register<Block> event)
{
event.getRegistry().register(
new Block(Material.ROCK)
.setRegistryName(MODID, "test")
.setUnlocalizedName(MODID + ".test")
.setCreativeTab(CreativeTabs.BUILDING_BLOCKS)
);
}
@SubscribeEvent
public static void registerItems(RegistryEvent.Register<Item> event)
{
event.getRegistry().registerAll(
new Item()
.setRegistryName(MODID, "item")
.setUnlocalizedName(MODID + ".item")
.setCreativeTab(CreativeTabs.MISC),
new ItemBlock(TEST_BLOCK)
.setRegistryName(TEST_BLOCK.getRegistryName())
);
}
//@Mod.EventBusSubscriber(modid = MODID, value = Side.CLIENT)
public static class ClientEventHandler
{
@SubscribeEvent
public static void registerModels(ModelRegistryEvent event)
{
ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(TEST_BLOCK), 0, new ModelResourceLocation(TEST_BLOCK.getRegistryName(), "normal"));
ModelLoader.setCustomModelResourceLocation(TEST_ITEM, 0, new ModelResourceLocation(MODID + ":test", "inventory"));
}
}
}
*/

View File

@ -1,103 +0,0 @@
/*
* Minecraft Forge
* Copyright (c) 2016-2019.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation version 2.1
* of the License.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
/*
package net.minecraftforge.debug.client.model;
import net.minecraft.client.renderer.model.ModelResourceLocation;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.Item;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.client.event.ModelRegistryEvent;
import net.minecraftforge.client.model.ModelLoader;
import net.minecraftforge.event.RegistryEvent;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.registry.GameRegistry;
//@Mod.EventBusSubscriber
//@Mod(modid = ItemModelGenerationTest.MOD_ID, name = "Item model generation test", version = "1.0", acceptableRemoteVersions = "*")
public class ItemModelGenerationTest
{
static final String MOD_ID = "item_model_generation_test";
@GameRegistry.ObjectHolder("animation_test")
public static final Item ANIMATION_TEST = null;
@GameRegistry.ObjectHolder("intersection_test")
public static final Item INTERSECTION_TEST = null;
@GameRegistry.ObjectHolder("opacity_test")
public static final Item OPACITY_TEST = null;
@GameRegistry.ObjectHolder("overlap_test")
public static final Item OVERLAP_TEST = null;
@GameRegistry.ObjectHolder("pattern_test")
public static final Item PATTERN_TEST = null;
@SubscribeEvent
public static void registerItems(RegistryEvent.Register<Item> event)
{
event.getRegistry().registerAll(
new Item()
.setRegistryName("animation_test")
.setUnlocalizedName(MOD_ID + ".animation_test")
.setCreativeTab(CreativeTabs.MISC),
new Item()
.setRegistryName("intersection_test")
.setUnlocalizedName(MOD_ID + ".intersection_test")
.setCreativeTab(CreativeTabs.MISC),
new Item()
.setRegistryName("opacity_test")
.setUnlocalizedName(MOD_ID + ".opacity_test")
.setCreativeTab(CreativeTabs.MISC),
new Item()
.setRegistryName("overlap_test")
.setUnlocalizedName(MOD_ID + ".overlap_test")
.setCreativeTab(CreativeTabs.MISC),
new Item()
.setRegistryName("pattern_test")
.setUnlocalizedName(MOD_ID + ".pattern_test")
.setCreativeTab(CreativeTabs.MISC)
);
}
//@Mod.EventBusSubscriber(modid = MOD_ID, value = Side.CLIENT)
public static class ClientEventHandler
{
@net.minecraftforge.eventbus.api.SubscribeEvent
public static void registerModels(ModelRegistryEvent event)
{
setCustomMRL(ANIMATION_TEST);
setCustomMRL(INTERSECTION_TEST);
setCustomMRL(OPACITY_TEST);
setCustomMRL(OVERLAP_TEST);
setCustomMRL(PATTERN_TEST);
}
private static void setCustomMRL(Item item)
{
ModelLoader.setCustomModelResourceLocation(item, 0, new ModelResourceLocation(item.getRegistryName(), "inventory"));
}
}
}
*/

View File

@ -1,394 +0,0 @@
/*
* Minecraft Forge
* Copyright (c) 2016-2019.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation version 2.1
* of the License.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
/*
package net.minecraftforge.debug.client.model;
import com.google.common.collect.ImmutableList;
import com.google.common.primitives.Ints;
import net.minecraft.block.Block;
import net.minecraft.block.BlockContainer;
import net.minecraft.block.material.Material;
import net.minecraft.block.properties.IProperty;
import net.minecraft.block.properties.PropertyInteger;
import net.minecraft.block.state.BlockStateContainer;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.model.BakedQuad;
import net.minecraft.client.renderer.model.IBakedModel;
import net.minecraft.client.renderer.model.ItemOverrideList;
import net.minecraft.client.renderer.model.ModelResourceLocation;
import net.minecraft.client.renderer.block.statemap.StateMapperBase;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemBlock;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.EnumBlockRenderType;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumHand;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Vec3d;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.client.event.ModelBakeEvent;
import net.minecraftforge.client.event.ModelRegistryEvent;
import net.minecraftforge.client.model.ModelLoader;
import net.minecraftforge.common.property.ExtendedBlockState;
import net.minecraftforge.common.property.IExtendedBlockState;
import net.minecraftforge.common.property.IUnlistedProperty;
import net.minecraftforge.common.property.Properties;
import net.minecraftforge.event.RegistryEvent;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.registry.GameRegistry;
import net.minecraftforge.fml.common.registry.GameRegistry.ObjectHolder;
import net.minecraftforge.api.distmarker.Dist;
import javax.annotation.Nullable;
import java.util.ArrayList;
import java.util.List;
//@Mod(modid = ModelBakeEventTest.MODID, name = "ForgeDebugModelBakeEvent", version = ModelBakeEventTest.VERSION, acceptableRemoteVersions = "*")
public class ModelBakeEventTest
{
public static final String MODID = "forgedebugmodelbakeevent";
public static final String VERSION = "1.0";
public static final int cubeSize = 3;
private static ResourceLocation blockName = new ResourceLocation(MODID, CustomModelBlock.name);
private static ModelResourceLocation blockLocation = new ModelResourceLocation(blockName, "normal");
private static ModelResourceLocation itemLocation = new ModelResourceLocation(blockName, "inventory");
@ObjectHolder(CustomModelBlock.name)
public static final Block CUSTOM_BLOCK = null;
@ObjectHolder(CustomModelBlock.name)
public static final Block CUSTOM_ITEM = null;
@SuppressWarnings("unchecked")
public static final IUnlistedProperty<Integer>[] properties = new IUnlistedProperty[6];
static
{
for (EnumFacing f : EnumFacing.values())
{
properties[f.ordinal()] = Properties.toUnlisted(PropertyInteger.create(f.getName(), 0, (1 << (cubeSize * cubeSize)) - 1));
}
}
//@Mod.EventBusSubscriber(modid = MODID)
public static class Registration
{
@SubscribeEvent
public static void registerBlocks(RegistryEvent.Register<Block> event)
{
event.getRegistry().register(new CustomModelBlock());
GameRegistry.registerTileEntity(CustomTileEntity.class, MODID.toLowerCase() + ":custom_tile_entity");
}
@SubscribeEvent
public static void registerItems(RegistryEvent.Register<Item> event)
{
event.getRegistry().register(new ItemBlock(CUSTOM_BLOCK).setRegistryName(CUSTOM_BLOCK.getRegistryName()));
}
}
//@Mod.EventBusSubscriber(value = Side.CLIENT, modid = MODID)
public static class BakeEventHandler
{
@SubscribeEvent
public static void registerModels(ModelRegistryEvent event)
{
Item item = Item.getItemFromBlock(CUSTOM_BLOCK);
ModelLoader.setCustomModelResourceLocation(item, 0, itemLocation);
ModelLoader.setCustomStateMapper(CUSTOM_BLOCK, new StateMapperBase()
{
protected ModelResourceLocation getModelResourceLocation(IBlockState p_178132_1_)
{
return blockLocation;
}
});
}
@SubscribeEvent
public static void onModelBakeEvent(ModelBakeEvent event)
{
TextureAtlasSprite base = Minecraft.getMinecraft().getTextureMapBlocks().getAtlasSprite("minecraft:blocks/slime");
TextureAtlasSprite overlay = Minecraft.getMinecraft().getTextureMapBlocks().getAtlasSprite("minecraft:blocks/redstone_block");
IBakedModel customModel = new CustomModel(base, overlay);
event.getModelRegistry().putObject(blockLocation, customModel);
event.getModelRegistry().putObject(itemLocation, customModel);
}
public static class CustomModel implements IBakedModel
{
private final TextureAtlasSprite base, overlay;
//private boolean hasStateSet = false;
public CustomModel(TextureAtlasSprite base, TextureAtlasSprite overlay)
{
this.base = base;
this.overlay = overlay;
}
// TODO update to builder
private int[] vertexToInts(float x, float y, float z, int color, TextureAtlasSprite texture, float u, float v)
{
return new int[]{
Float.floatToRawIntBits(x),
Float.floatToRawIntBits(y),
Float.floatToRawIntBits(z),
color,
Float.floatToRawIntBits(texture.getInterpolatedU(u)),
Float.floatToRawIntBits(texture.getInterpolatedV(v)),
0
};
}
private BakedQuad createSidedBakedQuad(float x1, float x2, float z1, float z2, float y, TextureAtlasSprite texture, EnumFacing side)
{
Vec3d v1 = rotate(new Vec3d(x1 - .5, y - .5, z1 - .5), side).addVector(.5, .5, .5);
Vec3d v2 = rotate(new Vec3d(x1 - .5, y - .5, z2 - .5), side).addVector(.5, .5, .5);
Vec3d v3 = rotate(new Vec3d(x2 - .5, y - .5, z2 - .5), side).addVector(.5, .5, .5);
Vec3d v4 = rotate(new Vec3d(x2 - .5, y - .5, z1 - .5), side).addVector(.5, .5, .5);
return new BakedQuad(Ints.concat(
vertexToInts((float) v1.x, (float) v1.y, (float) v1.z, -1, texture, 0, 0),
vertexToInts((float) v2.x, (float) v2.y, (float) v2.z, -1, texture, 0, 16),
vertexToInts((float) v3.x, (float) v3.y, (float) v3.z, -1, texture, 16, 16),
vertexToInts((float) v4.x, (float) v4.y, (float) v4.z, -1, texture, 16, 0)
), -1, side, texture, true, DefaultVertexFormats.BLOCK);
}
@Override
public List<BakedQuad> getQuads(@Nullable IBlockState state, @Nullable EnumFacing side, long rand)
{
if (side != null)
{
return ImmutableList.of();
}
IExtendedBlockState exState = (IExtendedBlockState) state;
int len = cubeSize * 5 + 1;
List<BakedQuad> ret = new ArrayList<BakedQuad>();
for (EnumFacing f : EnumFacing.values())
{
ret.add(createSidedBakedQuad(0, 1, 0, 1, 1, base, f));
if (state != null)
{
for (int i = 0; i < cubeSize; i++)
{
for (int j = 0; j < cubeSize; j++)
{
Integer value = exState.getValue(properties[f.ordinal()]);
if (value != null && (value & (1 << (i * cubeSize + j))) != 0)
{
ret.add(createSidedBakedQuad((float) (1 + i * 5) / len, (float) (5 + i * 5) / len, (float) (1 + j * 5) / len, (float) (5 + j * 5) / len, 1.0001f, overlay, f));
}
}
}
}
}
return ret;
}
@Override
public boolean isGui3d()
{
return true;
}
@Override
public boolean isAmbientOcclusion()
{
return true;
}
@Override
public boolean isBuiltInRenderer()
{
return false;
}
@Override
public TextureAtlasSprite getParticleTexture()
{
return this.base;
}
@Override
public ItemOverrideList getOverrides()
{
return ItemOverrideList.NONE;
}
}
}
public static class CustomModelBlock extends BlockContainer
{
public static final String name = "custom_model_block";
private CustomModelBlock()
{
super(Material.IRON);
setCreativeTab(CreativeTabs.BUILDING_BLOCKS);
setUnlocalizedName(MODID + ":" + name);
setRegistryName(blockName);
}
@Override
public EnumBlockRenderType getRenderType(IBlockState state)
{
return EnumBlockRenderType.MODEL;
}
@Override
public boolean isOpaqueCube(IBlockState state)
{
return false;
}
@Override
public boolean isFullCube(IBlockState state)
{
return false;
}
@Override
public boolean causesSuffocation(IBlockState state)
{
return false;
}
@Override
public TileEntity createNewTileEntity(World world, int meta)
{
return new CustomTileEntity();
}
@Override
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ)
{
TileEntity te = world.getTileEntity(pos);
if (te instanceof CustomTileEntity)
{
CustomTileEntity cte = (CustomTileEntity) te;
Vec3d vec = revRotate(new Vec3d(hitX - .5, hitY - .5, hitZ - .5), side).addVector(.5, .5, .5);
IUnlistedProperty<Integer> property = properties[side.ordinal()];
Integer value = cte.getState().getValue(property);
if (value == null)
{
value = 0;
}
value ^= (1 << (cubeSize * ((int) (vec.x * (cubeSize - .0001))) + ((int) (vec.z * (cubeSize - .0001)))));
cte.setState(cte.getState().withProperty(property, value));
world.markBlockRangeForRenderUpdate(pos, pos);
}
return true;
}
@Override
public IBlockState getExtendedState(IBlockState state, IBlockAccess world, BlockPos pos)
{
TileEntity te = world.getTileEntity(pos);
if (te instanceof CustomTileEntity)
{
CustomTileEntity cte = (CustomTileEntity) te;
return cte.getState();
}
return state;
}
@Override
protected BlockStateContainer createBlockState()
{
return new ExtendedBlockState(this, new IProperty[0], properties);
}
}
public static class CustomTileEntity extends TileEntity
{
private IExtendedBlockState state;
public CustomTileEntity()
{
}
public IExtendedBlockState getState()
{
if (state == null)
{
state = (IExtendedBlockState) getBlockType().getDefaultState();
}
return state;
}
public void setState(IExtendedBlockState state)
{
this.state = state;
}
}
@SuppressWarnings("SuspiciousNameCombination")
private static Vec3d rotate(Vec3d vec, EnumFacing side)
{
switch (side)
{
case DOWN:
return new Vec3d(vec.x, -vec.y, -vec.z);
case UP:
return new Vec3d(vec.x, vec.y, vec.z);
case NORTH:
return new Vec3d(vec.x, vec.z, -vec.y);
case SOUTH:
return new Vec3d(vec.x, -vec.z, vec.y);
case WEST:
return new Vec3d(-vec.y, vec.x, vec.z);
case EAST:
return new Vec3d(vec.y, -vec.x, vec.z);
}
throw new IllegalArgumentException("Unknown Side " + side);
}
@SuppressWarnings("SuspiciousNameCombination")
private static Vec3d revRotate(Vec3d vec, EnumFacing side)
{
switch (side)
{
case DOWN:
return new Vec3d(vec.x, -vec.y, -vec.z);
case UP:
return new Vec3d(vec.x, vec.y, vec.z);
case NORTH:
return new Vec3d(vec.x, -vec.z, vec.y);
case SOUTH:
return new Vec3d(vec.x, vec.z, -vec.y);
case WEST:
return new Vec3d(vec.y, -vec.x, vec.z);
case EAST:
return new Vec3d(-vec.y, vec.x, vec.z);
}
throw new IllegalArgumentException("Unknown Side " + side);
}
}
*/

View File

@ -1,193 +0,0 @@
/*
* Minecraft Forge
* Copyright (c) 2016-2019.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation version 2.1
* of the License.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
/*
package net.minecraftforge.debug.client.model;
import java.util.List;
import java.util.Random;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import net.minecraft.block.Block;
import net.minecraft.block.BlockRenderType;
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
import net.minecraft.block.ContainerBlock;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.model.BakedQuad;
import net.minecraft.client.renderer.model.IBakedModel;
import net.minecraft.client.renderer.model.ItemOverrideList;
import net.minecraft.client.renderer.model.ModelResourceLocation;
import net.minecraft.client.renderer.texture.MissingTextureSprite;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.tileentity.ITickableTileEntity;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.tileentity.TileEntityType;
import net.minecraft.util.Direction;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockReader;
import net.minecraft.world.ILightReader;
import net.minecraftforge.client.event.ModelBakeEvent;
import net.minecraftforge.client.model.ModelDataManager;
import net.minecraftforge.client.model.data.IDynamicBakedModel;
import net.minecraftforge.client.model.data.IModelData;
import net.minecraftforge.client.model.data.ModelDataMap;
import net.minecraftforge.client.model.data.ModelProperty;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.RegistryEvent;
import net.minecraftforge.eventbus.api.IEventBus;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
import net.minecraftforge.registries.ObjectHolder;
@Mod(ModelDataTest.MODID)
public class ModelDataTest
{
public static final String MODID = "forgedebugmodeldata";
public static final String VERSION = "1.0";
private static final ModelProperty<Boolean> MAGIC_PROP = new ModelProperty<Boolean>();
private static final String BLOCK_NAME = "block";
private static final String BLOCK_REGNAME = MODID + ":" + BLOCK_NAME;
@ObjectHolder(BLOCK_REGNAME)
public static final Block MY_BLOCK = null;
@ObjectHolder(BLOCK_REGNAME)
public static final TileEntityType<Tile> TILE_TYPE = null;
public ModelDataTest()
{
final IEventBus modEventBus = FMLJavaModLoadingContext.get().getModEventBus();
modEventBus.addGenericListener(Block.class, this::registerBlocks);
modEventBus.addGenericListener(TileEntityType.class, this::registerTileEntities);
MinecraftForge.EVENT_BUS.addListener(this::modelBake);
}
public void modelBake(ModelBakeEvent event)
{
final IBakedModel stone = event.getModelRegistry().get(new ModelResourceLocation("minecraft:stone"));
final IBakedModel dirt = event.getModelRegistry().get(new ModelResourceLocation("minecraft:dirt"));
event.getModelRegistry().put(new ModelResourceLocation(BLOCK_REGNAME, ""), new IDynamicBakedModel()
{
@Override
public boolean isGui3d()
{
return false;
}
@Override
public boolean isBuiltInRenderer()
{
return false;
}
@Override
public boolean isAmbientOcclusion()
{
return true;
}
@Override
public List<BakedQuad> getQuads(@Nullable BlockState state, @Nullable Direction side, Random rand, IModelData modelData)
{
return modelData.getData(MAGIC_PROP) ? stone.getQuads(state, side, rand, modelData) : dirt.getQuads(state, side, rand, modelData);
}
@Override
public TextureAtlasSprite getParticleTexture()
{
return MissingTextureSprite.func_217790_a();
}
@Override
public ItemOverrideList getOverrides()
{
return null;
}
@Override
@Nonnull
public IModelData getModelData(@Nonnull ILightReader world, @Nonnull BlockPos pos, @Nonnull BlockState state, @Nonnull IModelData tileData)
{
if (world.getBlockState(pos.down()).getBlock() == Blocks.AIR)
{
tileData.setData(MAGIC_PROP, !tileData.getData(MAGIC_PROP));
}
return tileData;
}
});
}
private static class Tile extends TileEntity implements ITickableTileEntity
{
public Tile()
{
super(TILE_TYPE);
}
private int counter;
@Override
public void tick()
{
if (world.isRemote && counter++ == 100)
{
ModelDataManager.requestModelDataRefresh(this);
world.markForRerender(getPos());
}
}
@Override
public IModelData getModelData()
{
return new ModelDataMap.Builder().withInitial(MAGIC_PROP, counter < 100).build();
}
}
public void registerBlocks(RegistryEvent.Register<Block> event)
{
event.getRegistry().register(new ContainerBlock(Block.Properties.create(Material.ROCK))
{
@Override
@Nullable
public TileEntity createNewTileEntity(IBlockReader worldIn)
{
return new Tile();
}
@Override
public BlockRenderType getRenderType(BlockState state)
{
return BlockRenderType.MODEL;
}
}.setRegistryName(MODID, BLOCK_NAME));
}
public void registerTileEntities(RegistryEvent.Register<TileEntityType<?>> event)
{
event.getRegistry().register(TileEntityType.Builder.func_223042_a(Tile::new, MY_BLOCK).build(null).setRegistryName(MODID, BLOCK_NAME));
}
}
*/

View File

@ -1,223 +0,0 @@
/*
* Minecraft Forge
* Copyright (c) 2016-2019.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation version 2.1
* of the License.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
/*
package net.minecraftforge.debug.client.model;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.renderer.model.ModelBakery;
import net.minecraft.client.renderer.model.ModelResourceLocation;
import net.minecraft.client.renderer.block.statemap.StateMapperBase;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.Item;
import net.minecraft.item.ItemBlock;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.client.event.ModelRegistryEvent;
import net.minecraftforge.client.model.ModelLoader;
import net.minecraftforge.common.ForgeVersion;
import net.minecraftforge.event.RegistryEvent;
import net.minecraftforge.fluids.BlockFluidClassic;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidRegistry;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.registry.GameRegistry.ObjectHolder;
//@Mod(modid = ModelFluidTest.MODID, name = "ForgeDebugModelFluid", version = ModelFluidTest.VERSION, acceptableRemoteVersions = "*")
public class ModelFluidTest
{
public static final String MODID = "forgedebugmodelfluid";
public static final String VERSION = "1.0";
public static final boolean ENABLE = false;
private static ModelResourceLocation fluidLocation = new ModelResourceLocation(MODID + ":" + TestFluidBlock.name, "fluid");
private static ModelResourceLocation gasLocation = new ModelResourceLocation(MODID + ":" + TestFluidBlock.name, "gas");
private static ModelResourceLocation milkLocation = new ModelResourceLocation(MODID + ":" + TestFluidBlock.name, "milk");
@ObjectHolder(TestFluidBlock.name)
public static final Block FLUID_BLOCK = null;
@ObjectHolder(TestFluidBlock.name)
public static final Item FLUID_ITEM = null;
@ObjectHolder(TestGasBlock.name)
public static final Block GAS_BLOCK = null;
@ObjectHolder(TestGasBlock.name)
public static final Item GAS_ITEM = null;
@ObjectHolder(MilkFluidBlock.name)
public static final Block MILK_BLOCK = null;
@ObjectHolder(MilkFluidBlock.name)
public static final Item MILK_ITEM = null;
//Used in DynBucketTest/FluidPlacementTest, TODO: Make this a full registry with @ObjectHolder?
public static final Fluid MILK = new Fluid("milk", new ResourceLocation(ForgeVersion.MOD_ID, "blocks/milk_still"), new ResourceLocation(ForgeVersion.MOD_ID, "blocks/milk_flow"));
public static final Fluid FLUID = new TestFluid();
public static final Fluid GAS = new TestGas();
//@Mod.EventBusSubscriber(modid = MODID)
public static class Registration
{
@SubscribeEvent
public static void registerBlocks(RegistryEvent.Register<Block> event)
{
if (!ENABLE)
return;
//TODO: Make FluidRegistry a full registry?
//Make a delegate system for FluidBlocks/Fluid Stacks?
//Fluids must be registered before a FluidStack can be made. Which is done in the block constructor
FluidRegistry.registerFluid(FLUID);
FluidRegistry.registerFluid(GAS);
FluidRegistry.registerFluid(MILK);
event.getRegistry().registerAll(
new TestFluidBlock(),
new TestGasBlock(),
new MilkFluidBlock()
);
}
@SubscribeEvent
public static void registerItems(RegistryEvent.Register<Item> event)
{
if (!ENABLE)
return;
event.getRegistry().registerAll(
new ItemBlock(FLUID_BLOCK).setRegistryName(FLUID_BLOCK.getRegistryName()),
new ItemBlock(GAS_BLOCK).setRegistryName(GAS_BLOCK.getRegistryName()),
new ItemBlock(MILK_BLOCK).setRegistryName(MILK_BLOCK.getRegistryName())
);
}
}
//@Mod.EventBusSubscriber(value = Side.CLIENT, modid = MODID)
public static class ClientEventHandler
{
@SubscribeEvent
public static void registerModels(ModelRegistryEvent event)
{
if (!ENABLE)
return;
// no need to pass the locations here, since they'll be loaded by the block model logic.
ModelBakery.registerItemVariants(FLUID_ITEM);
ModelBakery.registerItemVariants(GAS_ITEM);
ModelBakery.registerItemVariants(MILK_ITEM);
ModelLoader.setCustomMeshDefinition(FLUID_ITEM, is -> fluidLocation);
ModelLoader.setCustomMeshDefinition(GAS_ITEM, is -> gasLocation);
ModelLoader.setCustomMeshDefinition(MILK_ITEM, is -> milkLocation);
ModelLoader.setCustomStateMapper(FLUID_BLOCK, new StateMapperBase()
{
protected ModelResourceLocation getModelResourceLocation(IBlockState state)
{
return fluidLocation;
}
});
ModelLoader.setCustomStateMapper(GAS_BLOCK, new StateMapperBase()
{
protected ModelResourceLocation getModelResourceLocation(IBlockState state)
{
return gasLocation;
}
});
ModelLoader.setCustomStateMapper(MILK_BLOCK, new StateMapperBase()
{
protected ModelResourceLocation getModelResourceLocation(IBlockState state)
{
return milkLocation;
}
});
}
}
public static final class TestFluid extends Fluid
{
public static final String name = "testfluid";
private TestFluid()
{
super(name, new ResourceLocation("blocks/water_still"), new ResourceLocation("blocks/water_flow"), new ResourceLocation("blocks/water_overlay"));
}
@Override
public int getColor()
{
return 0xFF00FF00;
}
}
public static final class TestGas extends Fluid
{
public static final String name = "testgas";
private TestGas()
{
super(name, new ResourceLocation("blocks/lava_still"), new ResourceLocation("blocks/lava_flow"));
density = -1000;
isGaseous = true;
}
@Override
public int getColor()
{
return 0xFFFF0000;
}
}
public static final class TestFluidBlock extends BlockFluidClassic
{
public static final String name = "test_fluid_block";
private TestFluidBlock()
{
super(FLUID, Material.WATER);
setCreativeTab(CreativeTabs.BUILDING_BLOCKS);
setUnlocalizedName(MODID + ":" + name);
setRegistryName(new ResourceLocation(MODID, name));
}
}
public static final class MilkFluidBlock extends BlockFluidClassic
{
public static final String name = "milk_fluid_block";
private MilkFluidBlock()
{
super(MILK, Material.WATER);
setCreativeTab(CreativeTabs.BUILDING_BLOCKS);
setUnlocalizedName(MODID + ":" + name);
setRegistryName(new ResourceLocation(MODID, name));
}
}
public static final class TestGasBlock extends BlockFluidClassic
{
public static final String name = "test_gas_block";
private TestGasBlock()
{
super(GAS, Material.LAVA);
setCreativeTab(CreativeTabs.BUILDING_BLOCKS);
setUnlocalizedName(MODID + ":" + name);
setRegistryName(new ResourceLocation(MODID, name));
}
}
}
*/

View File

@ -1,844 +0,0 @@
/*
* Minecraft Forge
* Copyright (c) 2016-2019.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation version 2.1
* of the License.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
/*
package net.minecraftforge.debug.client.model;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import com.google.common.collect.UnmodifiableIterator;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.Minecraft;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.BlockItemUseContext;
import net.minecraft.item.Item;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemGroup;
import net.minecraft.state.BooleanProperty;
import net.minecraft.state.DirectionProperty;
import net.minecraft.state.StateContainer;
import net.minecraft.state.StateContainer.Builder;
import net.minecraft.state.properties.BlockStateProperties;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.tileentity.TileEntityType;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumHand;
import net.minecraft.util.ITickable;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.shapes.VoxelShape;
import net.minecraft.util.math.shapes.VoxelShapes;
import net.minecraft.util.text.TextComponentString;
import net.minecraft.world.IBlockReader;
import net.minecraft.world.IWorld;
import net.minecraft.world.World;
import net.minecraftforge.client.event.ModelRegistryEvent;
import net.minecraftforge.client.model.b3d.B3DLoader;
import net.minecraftforge.client.model.obj.OBJLoader;
import net.minecraftforge.common.model.Object;
import net.minecraftforge.common.model.IModelState;
import net.minecraftforge.common.model.Models;
import net.minecraftforge.common.model.TRSRTransformation;
import net.minecraftforge.event.RegistryEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.Mod.EventBusSubscriber.Bus;
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
import net.minecraftforge.registries.ObjectHolder;
//@Mod(ModelLoaderRegistryTest.MODID)
public class ModelLoaderRegistryTest
{
public static final boolean ENABLED = true;
public static final String MODID = "forgedebugmodelloaderregistry";
public static final String VERSION = "1.0";
private static Logger logger;
//@ObjectHolder(CustomModelBlock.name)
public static final Block CUSTOM_MODEL_BLOCK = null;
//@ObjectHolder(OBJTesseractBlock.name)
public static final Block TESSERACT_BLOCK = null;
//@ObjectHolder(OBJVertexColoring1.name)
public static final Block VERTEX_COLOR_1 = null;
//@ObjectHolder(OBJVertexColoring2.name)
public static final Block VERTEX_COLOR_2 = null;
//@ObjectHolder(OBJDirectionBlock.name)
public static final Block DIRECTION = null;
//@ObjectHolder(OBJDirectionEye.name)
public static final Block DIRECTION_EYE = null;
//@ObjectHolder(OBJDynamicEye.name)
public static final Block DYNAMIC_EYE = null;
//@ObjectHolder(OBJCustomDataBlock.name)
public static final Block CUSTOM_DATA = null;
//@ObjectHolder(OBJTesseractBlock.name)
public static final TileEntityType<OBJTesseractTileEntity> TESSERACT_TILE = null;
//@ObjectHolder(OBJVertexColoring2.name)
public static final TileEntityType<OBJVertexColoring2TileEntity> VERTEX_COLOR_2_TILE = null;
public ModelLoaderRegistryTest()
{
if (!ENABLED)
return;
logger = LogManager.getLogger();
FMLJavaModLoadingContext.get().getModEventBus().addListener(this::setupClient);
}
private void setupClient(FMLClientSetupEvent event)
{
B3DLoader.INSTANCE.addDomain(MODID);
OBJLoader.INSTANCE.addDomain(MODID);
}
@Mod.EventBusSubscriber(modid = MODID, bus = Bus.MOD)
public static class Registration
{
@net.minecraftforge.eventbus.api.SubscribeEvent
public static void registerBlocks(RegistryEvent.Register<Block> event)
{
if (!ENABLED)
return;
event.getRegistry().registerAll(
new CustomModelBlock(),
new OBJTesseractBlock(),
new OBJVertexColoring1(),
new OBJVertexColoring2(),
new OBJDirectionBlock(),
//new OBJDirectionEye(),
//new OBJDynamicEye(),
new OBJCustomDataBlock()
);
}
@SubscribeEvent
public static void registerTileEntities(RegistryEvent.Register<TileEntityType<?>> event)
{
event.getRegistry().registerAll(
new TileEntityType<>(OBJTesseractTileEntity::new, null).setRegistryName(OBJTesseractBlock.name),
new TileEntityType<>(OBJVertexColoring2TileEntity::new, null).setRegistryName(OBJVertexColoring2.name));
//GameRegistry.registerTileEntity(OBJDynamicEyeTileEntity.class, OBJDynamicEye.name);
}
@net.minecraftforge.eventbus.api.SubscribeEvent
public static void registerItems(RegistryEvent.Register<Item> event)
{
if (!ENABLED)
return;
Block[] blocks = {
CUSTOM_MODEL_BLOCK,
TESSERACT_BLOCK,
VERTEX_COLOR_1,
VERTEX_COLOR_2,
DIRECTION,
//DIRECTION_EYE,
//DYNAMIC_EYE,
CUSTOM_DATA
};
for (Block block : blocks)
event.getRegistry().register(new ItemBlock(block, new Item.Properties().group(ItemGroup.BUILDING_BLOCKS)).setRegistryName(block.getRegistryName()));
}
@net.minecraftforge.eventbus.api.SubscribeEvent
public static void registerModels(ModelRegistryEvent event)
{
if (!ENABLED)
return;
B3DLoader.INSTANCE.addDomain(MODID.toLowerCase());
OBJLoader.INSTANCE.addDomain(MODID.toLowerCase());
Block[] blocks = {
CUSTOM_MODEL_BLOCK,
TESSERACT_BLOCK,
VERTEX_COLOR_1,
VERTEX_COLOR_2,
DIRECTION,
//DIRECTION_EYE,
//DYNAMIC_EYE,
CUSTOM_DATA
};
}
}
static final VoxelShape SHAPE = VoxelShapes.create(1/16D, 1/16D, 1/16D, 15/16D, 15/16D, 15/16D); // We don't really care, just not solid
public static class CustomModelBlock extends Block
{
public static final DirectionProperty FACING = BlockStateProperties.FACING;
public static final String name = "custom_model_block";
private int counter = 1;
private CustomModelBlock()
{
super(Properties.create(Material.IRON));
this.setDefaultState(this.getStateContainer().getBaseState().with(FACING, EnumFacing.NORTH));
setRegistryName(new ResourceLocation(MODID, name));
}
@Override
public VoxelShape getRenderShape(IBlockState state, IBlockReader worldIn, BlockPos pos)
{
return SHAPE;
}
@Override
public boolean isFullCube(IBlockState state)
{
return false;
}
@Override
public boolean causesSuffocation(IBlockState state)
{
return false;
}
@Override
public IBlockState getStateForPlacement(BlockItemUseContext context)
{
return this.getDefaultState().with(FACING, context.getPlacementHorizontalFacing().getOpposite());
}
*/
/* @Override
public IBlockState getExtendedState(IBlockState state, IBlockAccess world, BlockPos pos)
{
//Only return an IExtendedBlockState from this method and createState(), otherwise block placement might break!
B3DLoader.B3DState newState = new B3DLoader.B3DState(null, counter);
return ((IExtendedBlockState) state).withProperty(Properties.AnimationProperty, newState);
}
*//*
@Override
public boolean onBlockActivated(IBlockState state, World world, BlockPos pos, EntityPlayer player, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ)
{
if (world.isRemote)
{
logger.info("click {}", counter);
if (player.isSneaking())
{
counter--;
}
else
{
counter++;
}
//if(counter >= model.getNode().getKeys().size()) counter = 0;
world.markBlockRangeForRenderUpdate(pos, pos);
}
return false;
}
@Override
public void fillStateContainer(StateContainer.Builder<Block, IBlockState> builder)
{
builder.add(FACING);
}
}
*/
/**
* This block is intended to demonstrate how to change the visibility of a group(s)
* from within the block's class.
* By right clicking on this block the player increments an integer value in the tile entity
* for this block, which is then added to a list of strings and passed into the constructor
* for OBJState. NOTE: this trick only works if your groups are named '1', '2', '3', etc.,
* otherwise they must be added by name.
* Holding shift decrements the value in the tile entity.
* @author shadekiller666
*
*//*
public static class OBJTesseractBlock extends Block
{
public static final String name = "obj_tesseract_block";
private OBJTesseractBlock()
{
super(Properties.create(Material.IRON));
setRegistryName(new ResourceLocation(MODID, name));
}
@Override
public boolean hasTileEntity()
{
return true;
}
@Override
public TileEntity createTileEntity(IBlockState state, IBlockReader world)
{
return new OBJTesseractTileEntity();
}
@Override
public VoxelShape getRenderShape(IBlockState state, IBlockReader worldIn, BlockPos pos)
{
return SHAPE;
}
@Override
public boolean isFullCube(IBlockState state)
{
return false;
}
@Override
public boolean causesSuffocation(IBlockState state)
{
return false;
}
@Override
public boolean onBlockActivated(IBlockState state, World world, BlockPos pos, EntityPlayer player, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ)
{
if (world.getTileEntity(pos) == null)
{
world.setTileEntity(pos, new OBJTesseractTileEntity());
}
OBJTesseractTileEntity tileEntity = (OBJTesseractTileEntity) world.getTileEntity(pos);
if (player.isSneaking())
{
tileEntity.decrement();
}
else
{
tileEntity.increment();
}
world.markBlockRangeForRenderUpdate(pos, pos);
return false;
}
@Override
public boolean hasTileEntity(IBlockState state)
{
return true;
}
*/
/* @Override
public IBlockState getExtendedState(IBlockState state, IBlockAccess world, BlockPos pos)
{
if (world.getTileEntity(pos) != null && world.getTileEntity(pos) instanceof OBJTesseractTileEntity)
{
OBJTesseractTileEntity te = (OBJTesseractTileEntity) world.getTileEntity(pos);
return ((IExtendedBlockState) state).withProperty(Properties.AnimationProperty, te.state);
}
return state;
}*//*
}
public static class OBJTesseractTileEntity extends TileEntity
{
private int counter = 1;
private int max = 32;
private final List<String> hidden = new ArrayList<String>();
private final IModelState state = new IModelState()
{
private final Optional<TRSRTransformation> value = Optional.of(TransformationMatrix.identity());
@Override
public Optional<TRSRTransformation> apply(Optional<? extends Object> part)
{
if (part.isPresent())
{
// This whole thing is subject to change, but should do for now.
UnmodifiableIterator<String> parts = Models.getParts(part.get());
if (parts.hasNext())
{
String name = parts.next();
// only interested in the root level
if (!parts.hasNext() && hidden.contains(name))
{
return value;
}
}
}
return Optional.empty();
}
};
public OBJTesseractTileEntity()
{
super(TESSERACT_TILE);
}
public void increment()
{
if (this.counter == max)
{
this.counter = 0;
this.hidden.clear();
}
this.counter++;
this.hidden.add(Integer.toString(this.counter));
TextComponentString text = new TextComponentString("" + this.counter);
if (this.world.isRemote)
{
Minecraft.getInstance().ingameGUI.getChatGUI().printChatMessage(text);
}
}
public void decrement()
{
if (this.counter == 1)
{
this.counter = max + 1;
for (int i = 1; i < max; i++) this.hidden.add(Integer.toString(i));
}
this.hidden.remove(Integer.toString(this.counter));
this.counter--;
TextComponentString text = new TextComponentString("" + this.counter);
if (this.world.isRemote)
{
Minecraft.getInstance().ingameGUI.getChatGUI().printChatMessage(text);
}
}
public void setMax(int max)
{
this.max = max;
}
}
*/
/**
* This block demonstrates how to utilize the vertex coloring feature
* of the OBJ loader. See 'vertex_coloring.obj' and 'vertex_coloring.mtl' in
* 'test/resources/assets/forgedebugmodelloaderregistry/models/block/', to properly
* utilize this feature an obj file must have 1 'usemtl' key before every vertex as shown,
* having less 'usemtl' lines than 'v' lines will result in the faces having that material's
* color instead of each vertex.
* @author shadekiller666
*
*//*
public static class OBJVertexColoring1 extends Block
{
public static final String name = "obj_vertex_coloring1";
private OBJVertexColoring1()
{
super(Properties.create(Material.IRON));
setRegistryName(new ResourceLocation(MODID, name));
}
@Override
public VoxelShape getRenderShape(IBlockState state, IBlockReader worldIn, BlockPos pos)
{
return SHAPE;
}
@Override
public boolean isFullCube(IBlockState state)
{
return false;
}
@Override
public boolean causesSuffocation(IBlockState state)
{
return false;
}
}
*/
/**
* This block demonstrates how to use IProperties and IUnlistedProperties together
* in the same ExtendedBlockState. Similar to pistons, this block will face the player
* when placed. Unlike pistons, however; this block's model is an eyeball, because
* the OBJ loader can load spheres.
* @author shadekiller666
*
*//*
public static class OBJDirectionEye extends Block
{
public static final DirectionProperty FACING = BlockStateProperties.FACING;
public static final String name = "obj_direction_eye";
private OBJDirectionEye()
{
super(Properties.create(Material.IRON));
setDefaultState(this.getStateContainer().getBaseState().with(FACING, EnumFacing.NORTH));
setRegistryName(new ResourceLocation(MODID, name));
}
@Override
public IBlockState getStateForPlacement(BlockItemUseContext context)
{
return this.getDefaultState().with(FACING, context.getPlacementHorizontalFacing().getOpposite());
}
@Override
public void fillStateContainer(StateContainer.Builder<Block, IBlockState> builder)
{
builder.add(FACING);
}
@Override
public VoxelShape getRenderShape(IBlockState state, IBlockReader worldIn, BlockPos pos)
{
return SHAPE;
}
@Override
public boolean isFullCube(IBlockState state)
{
return false;
}
@Override
public boolean causesSuffocation(IBlockState state)
{
return false;
}
}
*/
/**
* This block uses the same model as CustomModelBlock3 does, but
* this class allows the player to cycle the colors of each vertex to black
* and then back to the original color when right clicking on the block.
* @author shadekiller666
*
*//*
public static class OBJVertexColoring2 extends Block
{
public static final String name = "obj_vertex_coloring2";
private OBJVertexColoring2()
{
super(Properties.create(Material.IRON));
setRegistryName(new ResourceLocation(MODID, name));
}
@Override
public boolean hasTileEntity(IBlockState state)
{
return true;
}
@Override
public TileEntity createTileEntity(IBlockState state, IBlockReader world)
{
return new OBJVertexColoring2TileEntity();
}
@Override
public boolean onBlockActivated(IBlockState state, World world, BlockPos pos, EntityPlayer player, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ)
{
if (world.getTileEntity(pos) != null && world.getTileEntity(pos) instanceof OBJVertexColoring2TileEntity)
{
((OBJVertexColoring2TileEntity) world.getTileEntity(pos)).cycleColors();
}
return false;
}
}
@SuppressWarnings("unused")
public static class OBJVertexColoring2TileEntity extends TileEntity
{
private int index = 0;
private int maxIndex = 1;
private List<Vector4f> colorList = new ArrayList<Vector4f>();
private boolean hasFilledList = false;
private boolean shouldIncrement = true;
public OBJVertexColoring2TileEntity()
{
super(VERTEX_COLOR_2_TILE);
}
public void cycleColors()
{
if (this.world.isRemote)
{
logger.info(shouldIncrement);
*/
/*
IBakedModel bakedModel = Minecraft.getMinecraft().getBlockRendererDispatcher().getModelFromBlockState(this.world.getBlockState(this.pos), this.world, this.pos);
if (bakedModel != null && bakedModel instanceof OBJBakedModel)
{
OBJBakedModel objBaked = (OBJBakedModel) bakedModel;
ImmutableList<String> materialNames = objBaked.getModel().getMatLib().getMaterialNames();
if (!hasFilledList)
{
for (String name : materialNames)
{
if (!name.equals(OBJModel.Material.WHITE_NAME))
{
colorList.add(objBaked.getModel().getMatLib().getMaterial(name).getColor());
}
}
hasFilledList = true;
}
maxIndex = materialNames.size();
if (this.shouldIncrement && index + 1 < maxIndex)
{
FMLLog.info("incrementing");
String name = materialNames.get(index);
// no
objBaked.getModel().getMatLib().changeMaterialColor(name, 0xFF000000);
objBaked.scheduleRebake();
index++;
}
else if (index - 1 >= 0)
{
index--;
this.shouldIncrement = index == 0;
int color = 0;
color |= (int) (colorList.get(index).getW() * 255) << 24;
color |= (int) (colorList.get(index).getX() * 255) << 16;
color |= (int) (colorList.get(index).getY() * 255) << 8;
color |= (int) (colorList.get(index).getZ() * 255);
String name = materialNames.get(index);
if (!name.equals(OBJModel.Material.WHITE_NAME))
{
// FIXME
objBaked.getModel().getMatLib().changeMaterialColor(name, color);
objBaked.scheduleRebake();
}
}
this.world.markBlockRangeForRenderUpdate(this.pos, this.pos);
}*//*
}
}
}
*/
/**
* This block is a debug block that faces the player when placed, like a piston.
* @author shadekiller666
*
*//*
public static class OBJDirectionBlock extends Block
{
public static final DirectionProperty FACING = BlockStateProperties.FACING;
public static final String name = "obj_direction_block";
private OBJDirectionBlock()
{
super(Properties.create(Material.IRON));
this.setDefaultState(this.getStateContainer().getBaseState().with(FACING, EnumFacing.NORTH));
setRegistryName(new ResourceLocation(MODID, name));
}
@Override
public VoxelShape getRenderShape(IBlockState state, IBlockReader worldIn, BlockPos pos)
{
return SHAPE;
}
@Override
public boolean isFullCube(IBlockState state)
{
return false;
}
@Override
public boolean causesSuffocation(IBlockState state)
{
return false;
}
@Override
public IBlockState getStateForPlacement(BlockItemUseContext context)
{
return this.getDefaultState().with(FACING, context.getPlacementHorizontalFacing().getOpposite());
}
@Override
public void fillStateContainer(StateContainer.Builder<Block, IBlockState> builder)
{
builder.add(FACING);
}
}
*/
/**
* This block is a testing block that will be used to test the use
* of "custom" data defined in a forge blockstate json. WIP, ignore for now.
* @author shadekiller666
*
*//*
public static class OBJCustomDataBlock extends Block
{
public static final BooleanProperty NORTH = BooleanProperty.create("north");
public static final BooleanProperty SOUTH = BooleanProperty.create("south");
public static final BooleanProperty WEST = BooleanProperty.create("west");
public static final BooleanProperty EAST = BooleanProperty.create("east");
public static final String name = "obj_custom_data_block";
private OBJCustomDataBlock()
{
super(Properties.create(Material.IRON));
this.setDefaultState(this.getStateContainer().getBaseState().with(NORTH, false).with(SOUTH, false).with(WEST, false).with(EAST, false));
setRegistryName(new ResourceLocation(MODID, name));
}
@Override
public VoxelShape getRenderShape(IBlockState state, IBlockReader worldIn, BlockPos pos)
{
return SHAPE;
}
@Override
public boolean isFullCube(IBlockState state)
{
return false;
}
public boolean canConnectTo(IBlockReader world, BlockPos pos)
{
Block block = world.getBlockState(pos).getBlock();
return block instanceof OBJCustomDataBlock;
}
@Override
public IBlockState updatePostPlacement(IBlockState state, EnumFacing facing, IBlockState facingState, IWorld world, BlockPos pos, BlockPos facingPos)
{
return state.with(NORTH, this.canConnectTo(world, pos.north())).with(SOUTH, this.canConnectTo(world, pos.south())).with(WEST, this.canConnectTo(world, pos.west())).with(EAST, this.canConnectTo(world, pos.east()));
}
@Override
protected void fillStateContainer(Builder<Block, IBlockState> builder)
{
builder.add(NORTH, SOUTH, WEST, EAST);
}
}
*/
/**
* This block uses the same model as CustomModelBlock4, but instead of facing the
* player when placed, this one ALWAYS faces the player. I know, creepy right?
* @author shadekiller666
*
*//*
public static class OBJDynamicEye extends Block
{
public static final String name = "obj_dynamic_eye";
private OBJDynamicEye()
{
super(Properties.create(Material.IRON));
setRegistryName(new ResourceLocation(MODID, name));
}
@Override
public TileEntity createTileEntity(IBlockState state, IBlockReader world)
{
return new OBJDynamicEyeTileEntity();
}
@Override
public VoxelShape getRenderShape(IBlockState state, IBlockReader worldIn, BlockPos pos)
{
return SHAPE;
}
@Override
public boolean isFullCube(IBlockState state)
{
return false;
}
@Override
public boolean hasTileEntity(IBlockState state)
{
return true;
}
*/
/* @Override
public IBlockState getExtendedState(IBlockState state, IBlockAccess world, BlockPos pos)
{
if (world.getTileEntity(pos) != null && world.getTileEntity(pos) instanceof OBJDynamicEyeTileEntity)
{
OBJDynamicEyeTileEntity te = (OBJDynamicEyeTileEntity) world.getTileEntity(pos);
if (te.transform != TransformationMatrix.identity())
{
return ((IExtendedBlockState) state).withProperty(Properties.AnimationProperty, te.transform);
}
}
return state;
}*//*
}
public static class OBJDynamicEyeTileEntity extends TileEntity implements ITickable
{
public OBJDynamicEyeTileEntity()
{
super(null); // TODO
}
private TRSRTransformation transform = TransformationMatrix.identity();
@Override
public void tick()
{
if (this.world.isRemote)
{
Vector3d teLoc = new Vector3d(this.getPos().getX(), this.getPos().getY(), this.getPos().getZ());
EntityPlayer player = Minecraft.getInstance().player;
Vector3d playerLoc = new Vector3d();
playerLoc.setX(player.posX);
playerLoc.setY(player.posY + player.getEyeHeight());
playerLoc.setZ(player.posZ);
Vector3d lookVec = new Vector3d(playerLoc.getX() - teLoc.getX(), playerLoc.getY() - teLoc.getY(), playerLoc.getZ() - teLoc.getZ());
double angleYaw = Math.atan2(lookVec.getZ(), lookVec.getX()) - Math.PI / 2d;
double anglePitch = Math.atan2(lookVec.getY(), Math.sqrt(lookVec.getX() * lookVec.getX() + lookVec.getZ() * lookVec.getZ()));
AxisAngle4d yaw = new AxisAngle4d(0, 1, 0, -angleYaw);
AxisAngle4d pitch = new AxisAngle4d(1, 0, 0, -anglePitch);
Quat4f rot = new Quat4f(0, 0, 0, 1);
Quat4f yawQuat = new Quat4f();
Quat4f pitchQuat = new Quat4f();
yawQuat.set(yaw);
rot.mul(yawQuat);
pitchQuat.set(pitch);
rot.mul(pitchQuat);
Matrix4f matrix = new Matrix4f();
matrix.setIdentity();
matrix.setRotation(rot);
transform = TRSRTransformation.blockCenterToCorner(new TRSRTransformation(matrix));
this.world.markBlockRangeForRenderUpdate(this.pos, this.pos);
}
}
}
}
*/

View File

@ -1,25 +0,0 @@
/*
* Minecraft Forge
* Copyright (c) 2016-2019.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation version 2.1
* of the License.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
@ParametersAreNonnullByDefault
@MethodsReturnNonnullByDefault
package net.minecraftforge.debug.client;
import javax.annotation.ParametersAreNonnullByDefault;
import mcp.MethodsReturnNonnullByDefault;

View File

@ -1,271 +0,0 @@
/*
* Minecraft Forge
* Copyright (c) 2016-2019.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation version 2.1
* of the License.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
/*
package net.minecraftforge.debug.client.rendering;
import java.util.Collections;
import java.util.List;
import java.util.Optional;
import net.minecraft.block.Block;
import net.minecraft.block.BlockContainer;
import net.minecraft.block.material.Material;
import net.minecraft.block.properties.PropertyInteger;
import net.minecraft.block.state.BlockStateContainer;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.BufferBuilder;
import net.minecraft.client.renderer.model.ModelBakery;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.client.util.ITooltipFlag;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.item.Item;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumHand;
import net.minecraft.util.NonNullList;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.client.event.ModelRegistryEvent;
import net.minecraftforge.client.model.ModelLoader;
import net.minecraftforge.client.model.animation.FastTESR;
import net.minecraftforge.event.RegistryEvent;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidRegistry;
import net.minecraftforge.fml.client.registry.ClientRegistry;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.Mod.EventBusSubscriber;
import net.minecraftforge.fml.common.Mod.EventHandler;
import net.minecraftforge.fml.event.FMLPreInitializationEvent;
import net.minecraftforge.fml.common.registry.GameRegistry;
import net.minecraftforge.api.distmarker.Dist;
//@Mod(modid = FastTESRTransparentTest.MODID, name = "TransparentFastTESRTest", version = "1.0", acceptableRemoteVersions = "*")
public class FastTESRTransparentTest
{
static final String MODID = "transparent_fast_tesr_test";
private static class TransparentFastTESR extends FastTESR<TransparentFastTE>
{
private static TextureAtlasSprite getFluidTexture(Fluid fluid)
{
final ResourceLocation textureLocation = fluid.getStill();
return Minecraft.getMinecraft().getTextureMapBlocks().getAtlasSprite(textureLocation.toString());
}
private static void addVertexWithUV(BufferBuilder wr, double x, double y, double z, double u, double v, int skyLight, int blockLight)
{
wr.pos(x, y, z).color(0xFF, 0xFF, 0xFF, 0xFF).tex(u, v).lightmap(skyLight, blockLight).endVertex();
}
@Override
public void renderTileEntityFast(TransparentFastTE te, double x, double y, double z, float partialTicks, int destroyStage, float partial, BufferBuilder wr)
{
if (te.fluid == null)
return;
final int skyLight = 0x00f0;
final int blockLight = 0x00f0;
final TextureAtlasSprite texture = getFluidTexture(te.fluid);
final double uMin = texture.getMinU();
final double uMax = texture.getMaxU();
final double vMin = texture.getMinV();
final double vMax = texture.getMaxV();
wr.setTranslation(x, y, z);
addVertexWithUV(wr, 1, 0, 0, uMax, vMin, skyLight, blockLight);
addVertexWithUV(wr, 1, 1, 0, uMax, vMax, skyLight, blockLight);
addVertexWithUV(wr, 0, 1, 0, uMin, vMax, skyLight, blockLight);
addVertexWithUV(wr, 0, 0, 0, uMin, vMin, skyLight, blockLight);
addVertexWithUV(wr, 1, 0, 1, uMin, vMin, skyLight, blockLight);
addVertexWithUV(wr, 1, 1, 1, uMin, vMax, skyLight, blockLight);
addVertexWithUV(wr, 0, 1, 1, uMax, vMax, skyLight, blockLight);
addVertexWithUV(wr, 0, 0, 1, uMax, vMin, skyLight, blockLight);
addVertexWithUV(wr, 1, 0, 0, uMin, vMin, skyLight, blockLight);
addVertexWithUV(wr, 1, 1, 0, uMin, vMax, skyLight, blockLight);
addVertexWithUV(wr, 1, 1, 1, uMax, vMax, skyLight, blockLight);
addVertexWithUV(wr, 1, 0, 1, uMax, vMin, skyLight, blockLight);
addVertexWithUV(wr, 0, 0, 1, uMin, vMin, skyLight, blockLight);
addVertexWithUV(wr, 0, 1, 1, uMin, vMax, skyLight, blockLight);
addVertexWithUV(wr, 0, 1, 0, uMax, vMax, skyLight, blockLight);
addVertexWithUV(wr, 0, 0, 0, uMax, vMin, skyLight, blockLight);
addVertexWithUV(wr, 1, 0, 0, uMax, vMin, skyLight, blockLight);
addVertexWithUV(wr, 1, 0, 1, uMin, vMin, skyLight, blockLight);
addVertexWithUV(wr, 0, 0, 1, uMin, vMax, skyLight, blockLight);
addVertexWithUV(wr, 0, 0, 0, uMax, vMax, skyLight, blockLight);
addVertexWithUV(wr, 1, 1, 0, uMax, vMin, skyLight, blockLight);
addVertexWithUV(wr, 0, 1, 0, uMax, vMax, skyLight, blockLight);
addVertexWithUV(wr, 0, 1, 1, uMin, vMax, skyLight, blockLight);
addVertexWithUV(wr, 1, 1, 1, uMin, vMin, skyLight, blockLight);
wr.setTranslation(0, 0, 0);
}
}
public static class TransparentFastTE extends TileEntity
{
private final Fluid fluid;
public TransparentFastTE()
{
this(null);
}
public TransparentFastTE(Fluid fluid)
{
this.fluid = fluid;
}
@Override
public boolean hasFastRenderer()
{
return true;
}
@Override
public boolean shouldRenderInPass(int pass)
{
return pass == 1;
}
}
public static final PropertyInteger FLUID = PropertyInteger.create("fluid", 0, 15);
private static Optional<Fluid> getNthFluid(int meta)
{
return FluidRegistry.getRegisteredFluids().values().stream().skip(meta).findFirst();
}
private static final Block testBlock = new BlockContainer(Material.CORAL)
{
@Override
public TileEntity createNewTileEntity(World worldIn, int meta)
{
Optional<Fluid> maybeFluid = getNthFluid(meta);
return maybeFluid.map(TransparentFastTE::new).orElse(null);
}
@Override
public IBlockState getStateForPlacement(World world, BlockPos pos, EnumFacing facing, float hitX, float hitY, float hitZ, int meta, EntityLivingBase placer, EnumHand hand)
{
final ItemStack held = placer.getHeldItem(hand);
return getDefaultState().withProperty(FLUID, Math.min(held.getMetadata(), 15));
}
@Override
protected BlockStateContainer createBlockState()
{
return new BlockStateContainer(this, FLUID);
}
@Override
public int getMetaFromState(IBlockState state)
{
return state.getValue(FLUID);
}
@Override
public IBlockState getStateFromMeta(int meta)
{
return getDefaultState().withProperty(FLUID, meta);
}
@Override
public boolean isOpaqueCube(IBlockState state)
{
return false;
}
@Override
public void getSubBlocks(CreativeTabs itemIn, NonNullList<ItemStack> items)
{
final int fluidCount = Math.min(FluidRegistry.getRegisteredFluids().size(), 15);
for (int i = 0; i < fluidCount; i++)
items.add(new ItemStack(this, 1, i));
}
};
//@EventBusSubscriber
public static class BlockHolder
{
@net.minecraftforge.eventbus.api.SubscribeEvent
public static void onBlockRegister(RegistryEvent.Register<Block> evt)
{
evt.getRegistry().register(testBlock
.setCreativeTab(CreativeTabs.DECORATIONS)
.setRegistryName("fluid-tesr-block"));
}
@net.minecraftforge.eventbus.api.SubscribeEvent
public static void onItemRegister(RegistryEvent.Register<Item> evt)
{
evt.getRegistry().register(new ItemBlock(testBlock)
{
@Override
public void addInformation(ItemStack stack, World worldIn, List<String> tooltip, ITooltipFlag flagIn)
{
final Optional<Fluid> nthFluid = getNthFluid(stack.getMetadata());
if (nthFluid.isPresent())
{
tooltip.add("Fluid: " + nthFluid.get().getName());
}
}
}
.setHasSubtypes(true)
.setRegistryName("tesr-test"));
}
}
@EventHandler
public void preInit(FMLPreInitializationEvent evt)
{
GameRegistry.registerTileEntity(TransparentFastTE.class, MODID + ":fast-tesr-te");
}
//@EventBusSubscriber(value = Side.CLIENT, modid = MODID)
public static class ClientLoader
{
@net.minecraftforge.eventbus.api.SubscribeEvent
public static void registerModels(ModelRegistryEvent event)
{
ModelLoader.setCustomStateMapper(testBlock, block -> Collections.emptyMap());
ModelBakery.registerItemVariants(Item.getItemFromBlock(testBlock));
ClientRegistry.bindTileEntitySpecialRenderer(TransparentFastTE.class, new TransparentFastTESR());
}
}
}
*/

View File

@ -1,167 +0,0 @@
/*
* Minecraft Forge
* Copyright (c) 2016-2019.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation version 2.1
* of the License.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
/*
package net.minecraftforge.debug.client.rendering;
import net.minecraft.block.Block;
import net.minecraft.block.BlockContainer;
import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.model.ModelResourceLocation;
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.Item;
import net.minecraft.item.ItemBlock;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ResourceLocation;
import net.minecraft.world.World;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.client.ForgeHooksClient;
import net.minecraftforge.client.event.ModelBakeEvent;
import net.minecraftforge.client.event.ModelRegistryEvent;
import net.minecraftforge.client.model.ModelLoader;
import net.minecraftforge.event.RegistryEvent;
import net.minecraftforge.fml.client.registry.ClientRegistry;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.registry.ForgeRegistries;
import net.minecraftforge.fml.common.registry.GameRegistry;
import net.minecraftforge.fml.common.registry.GameRegistry.ObjectHolder;
import static org.lwjgl.opengl.GL11.*;
//@Mod(modid = ItemTESRTest.MODID, name = "ForgeDebugItemTile", version = "1.0", acceptableRemoteVersions = "*")
public class ItemTESRTest
{
public static final String MODID = "forgedebugitemtile";
@ObjectHolder(TestBlock.name)
public static final Block TEST_BLOCK = null;
//@Mod.EventBusSubscriber(modid = MODID)
public static class Registration
{
@net.minecraftforge.eventbus.api.SubscribeEvent
public static void registerBlocks(RegistryEvent.Register<Block> event)
{
event.getRegistry().register(new TestBlock());
GameRegistry.registerTileEntity(CustomTileEntity.class, MODID.toLowerCase() + ":custom_tile_entity");
}
@net.minecraftforge.eventbus.api.SubscribeEvent
public static void registerItems(RegistryEvent.Register<Item> event)
{
event.getRegistry().register(new ItemBlock(TEST_BLOCK).setRegistryName(TEST_BLOCK.getRegistryName()));
}
}
//@Mod.EventBusSubscriber(value = Side.CLIENT, modid = MODID)
public static class BakeEventHandler
{
@SubscribeEvent
public static void registerModels(ModelRegistryEvent event)
{
final ModelResourceLocation itemLocation = new ModelResourceLocation(TEST_BLOCK.getRegistryName(), "normal");
Item item = ForgeRegistries.ITEMS.getValue(new ResourceLocation(MODID, TestBlock.name));
ForgeHooksClient.registerTESRItemStack(item, 0, CustomTileEntity.class);
ModelLoader.setCustomModelResourceLocation(item, 0, itemLocation);
ClientRegistry.bindTileEntitySpecialRenderer(CustomTileEntity.class, TestTESR.instance);
}
@net.minecraftforge.eventbus.api.SubscribeEvent
public static void onModelBakeEvent(ModelBakeEvent event)
{
event.getModelManager().getBlockModelShapes().registerBuiltInBlocks(TEST_BLOCK);
}
public static class TestTESR extends TileEntitySpecialRenderer<CustomTileEntity>
{
private static final TestTESR instance = new TestTESR();
private TestTESR()
{
}
@Override
public void render(CustomTileEntity p_180535_1_, double x, double y, double z, float p_180535_8_, int p_180535_9_, float partial)
{
glPushMatrix();
glTranslated(x, y, z);
GlStateManager.disableTexture2D();
GlStateManager.disableLighting();
glColor4f(.2f, 1, .1f, 1);
glBegin(GL_QUADS);
glVertex3f(0, .5f, 0);
glVertex3f(0, .5f, 1);
glVertex3f(1, .5f, 1);
glVertex3f(1, .5f, 0);
glEnd();
glPopMatrix();
GlStateManager.enableTexture2D();
GlStateManager.enableLighting();
}
}
}
public static class TestBlock extends BlockContainer
{
public static final String name = "custom_model_block";
private TestBlock()
{
super(Material.IRON);
setCreativeTab(CreativeTabs.BUILDING_BLOCKS);
setUnlocalizedName(MODID + ":" + name);
setRegistryName(new ResourceLocation(MODID, name));
}
@Override
public boolean isOpaqueCube(IBlockState state)
{
return false;
}
@Override
public boolean isFullCube(IBlockState state)
{
return false;
}
@Override
public boolean causesSuffocation(IBlockState state)
{
return false;
}
@Override
public TileEntity createNewTileEntity(World world, int meta)
{
return new CustomTileEntity();
}
}
public static class CustomTileEntity extends TileEntity
{
}
}
*/

View File

@ -1,118 +0,0 @@
/*
* Minecraft Forge
* Copyright (c) 2016-2019.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation version 2.1
* of the License.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
/*
package net.minecraftforge.debug.client.rendering;
import net.minecraft.client.model.ModelBase;
import net.minecraft.client.model.ModelRenderer;
import net.minecraft.client.renderer.entity.RenderLivingBase;
import net.minecraft.client.renderer.entity.RenderManager;
import net.minecraft.entity.Entity;
import net.minecraft.entity.item.EntityArmorStand;
import net.minecraft.util.ResourceLocation;
import net.minecraft.world.World;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.fml.DistExecutor;
import net.minecraftforge.fml.client.registry.RenderingRegistry;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.Mod.EventHandler;
import net.minecraftforge.fml.common.Mod.Instance;
import net.minecraftforge.fml.event.FMLPreInitializationEvent;
import net.minecraftforge.fml.common.registry.EntityRegistry;
//@Mod(modid = "wrnormal", name = "WRNormal", version = "1.0", acceptableRemoteVersions = "*")
public class VertexBufferNormalTest
{
@Instance("wrnormal")
public static VertexBufferNormalTest instance;
@EventHandler
public void init(FMLPreInitializationEvent event)
{
EntityRegistry.registerModEntity(new ResourceLocation("wrnormal", "scale_test"), EntityScaleTest.class, "scale_test", 0, instance, 60, 3, true);
DistExecutor.runWhenOn(Dist.CLIENT, ()-> () -> RenderingRegistry.registerEntityRenderingHandler(EntityScaleTest.class, RenderScaleTest::new));
}
public static class RenderScaleTestFactory implements IRenderFactory<EntityScaleTest>
{
@Override
public RenderScaleTest createRenderFor(RenderManager manager)
{
return new RenderScaleTest(manager);
}
}
public static class EntityScaleTest extends EntityArmorStand
{
public EntityScaleTest(World world)
{
super(world);
}
}
public static class RenderScaleTest extends RenderLivingBase<EntityScaleTest>
{
private static final ResourceLocation TEXTURE = new ResourceLocation("textures/blocks/stone.png");
public RenderScaleTest(RenderManager manager)
{
super(manager, new ModelScaleTest(), 0);
}
@Override
public void renderName(EntityScaleTest entity, double x, double y, double z)
{
}
@Override
protected ResourceLocation getEntityTexture(EntityScaleTest entity)
{
return TEXTURE;
}
}
public static class ModelScaleTest extends ModelBase
{
private ModelRenderer component;
public ModelScaleTest()
{
textureWidth = textureHeight = 16;
component = new ModelRenderer(this);
int size = 10;
for (int x = 0; x < size; x++)
{
for (int z = 0; z < size; z++)
{
component.addBox((x - size / 2) * 3, 0, (z - size / 2) * 3, 2, 2, 2, -(x + z * size) / (float) (size * size) * 0.5F);
}
}
}
@Override
public void render(Entity entity, float p1, float p2, float p3, float p4, float p5, float scale)
{
component.render(scale);
}
}
}
*/

View File

@ -1,76 +0,0 @@
/*
* Minecraft Forge
* Copyright (c) 2016-2019.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation version 2.1
* of the License.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
/*
package net.minecraftforge.debug.entity;
import net.minecraft.command.CommandBase;
import net.minecraft.command.CommandException;
import net.minecraft.command.ICommandSender;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.server.MinecraftServer;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.event.FMLServerStartingEvent;
//@Mod(modid = "entityupdateblockedtest", name = "Entity Update Blocked Test", version = "1.0.0", acceptableRemoteVersions = "*")
public class BlockEntityUpdateTest
{
@Mod.EventHandler
public void init(FMLServerStartingEvent event)
{
event.registerServerCommand(new BlockEntityUpdateCommand());
}
private class BlockEntityUpdateCommand extends CommandBase
{
@Override
public String getName()
{
return "blockEntityUpdate";
}
@Override
public String getUsage(ICommandSender sender)
{
return "blockEntityUpdate <value>";
}
@Override
public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException
{
if (args.length != 1)
{
return;
}
boolean value = Boolean.parseBoolean(args[0]);
for (Entity ent : sender.getEntityWorld().loadedEntityList)
{
if (!(ent instanceof EntityPlayer))
{
ent.updateBlocked = value;
}
}
}
}
}
*/

View File

@ -1,59 +0,0 @@
/*
* Minecraft Forge
* Copyright (c) 2016-2019.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation version 2.1
* of the License.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
/*
package net.minecraftforge.debug.entity;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.entity.EntityTravelToDimensionEvent;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.Mod.EventHandler;
import net.minecraftforge.fml.event.FMLPreInitializationEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import org.apache.logging.log4j.Logger;
//@Mod(modid = "entitytraveltodimensioneventtest", name = "EntityTravelToDimensionEventTest", version = "0.0.0", acceptableRemoteVersions = "*")
public class EntityTravelToDimensionEventTest
{
public static final boolean ENABLE = false;
private static Logger logger;
@EventHandler
public void preInit(FMLPreInitializationEvent event)
{
if (ENABLE)
{
logger = event.getModLog();
MinecraftForge.EVENT_BUS.register(this);
}
}
@SubscribeEvent
public void onDimensionTravel(EntityTravelToDimensionEvent event)
{
if (ENABLE)
{
logger.info("Travelling to Dimension {} Entity: {}", event.getDimension(), event.getEntity());
event.setCanceled(true);
}
}
}
*/

View File

@ -1,123 +0,0 @@
/*
* Minecraft Forge
* Copyright (c) 2016-2019.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation version 2.1
* of the License.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
/*
package net.minecraftforge.debug.entity;
import java.util.ArrayList;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.item.Item;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Vec3d;
import net.minecraft.world.World;
import net.minecraftforge.event.RegistryEvent;
import net.minecraftforge.event.world.GetCollisionBoxesEvent;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.registry.GameRegistry;
//@Mod(modid = GetCollisionBoxesEventTest.MODID, name = "CollisionBoxesEventTest", version = "1.0", acceptableRemoteVersions = "*")
//@Mod.EventBusSubscriber
public class GetCollisionBoxesEventTest
{
public static final String MODID = "collisionboxexeventtest";
public static final boolean ENABLED = true;
@GameRegistry.ObjectHolder("box_block")
private static final Block BOX_BLOCK = null;
private static final ArrayList<BlockPos> locations = new ArrayList<>();
@net.minecraftforge.eventbus.api.SubscribeEvent
public static void registerBlock(RegistryEvent.Register<Block> event)
{
if (ENABLED)
{
event.getRegistry().register(new BoxBlock());
}
}
@SubscribeEvent
public static void registerItem(RegistryEvent.Register<Item> event)
{
if (ENABLED)
{
event.getRegistry().register(new ItemBlock(BOX_BLOCK).setRegistryName(new ResourceLocation(MODID, "box_block")));
}
}
@SubscribeEvent
public static void getBoxes(GetCollisionBoxesEvent event)
{
AxisAlignedBB box = event.getAabb();
for (BlockPos pos: locations)
{
for (EnumFacing facing: EnumFacing.HORIZONTALS)
{
AxisAlignedBB temp = new AxisAlignedBB(pos).offset(new Vec3d(facing.getDirectionVec()));
if (box.intersects(temp))
event.getCollisionBoxesList().add(temp);
}
}
}
private static class BoxBlock extends Block
{
public BoxBlock()
{
super(Material.ROCK);
setRegistryName(new ResourceLocation(MODID, "box_block"));
setCreativeTab(CreativeTabs.MISC);
}
@Override
public void breakBlock(World worldIn, BlockPos pos, IBlockState state)
{
locations.remove(pos);
}
@Override
public void onBlockPlacedBy(World worldIn, BlockPos pos, IBlockState state, EntityLivingBase placer, ItemStack stack)
{
locations.add(pos);
}
@Override
public String getUnlocalizedName() {
return "CollisionBoxes event test block";
}
}
}*/

View File

@ -1,55 +0,0 @@
/*
* Minecraft Forge
* Copyright (c) 2016-2019.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation version 2.1
* of the License.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
/*
package net.minecraftforge.debug.entity;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.entity.ProjectileImpactEvent;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.event.FMLPreInitializationEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import org.apache.logging.log4j.Logger;
//@Mod(modid = "projectile_event_test", name = "ProjectileImpactEvent test mod", version = "1.0", acceptableRemoteVersions = "*")
public class ProjectileImpactEventTest
{
private static final boolean ENABLED = false;
private static Logger logger;
@Mod.EventHandler
public void preInit(FMLPreInitializationEvent event)
{
logger = event.getModLog();
if (ENABLED)
{
MinecraftForge.EVENT_BUS.register(ProjectileImpactEventTest.class);
}
}
@net.minecraftforge.eventbus.api.SubscribeEvent
public static void onProjectileImpact(ProjectileImpactEvent event)
{
logger.info("projectile: {}, impact: {}", event.getEntity().getName(), event.getRayTraceResult());
}
}
*/

View File

@ -1,51 +0,0 @@
/*
* Minecraft Forge
* Copyright (c) 2016-2019.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation version 2.1
* of the License.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
/*
package net.minecraftforge.debug.entity.living;
import net.minecraft.entity.passive.EntityWolf;
import net.minecraftforge.event.entity.living.AnimalTameEvent;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
//@Mod(modid = AnimalTameEventTest.MOD_ID, name = "AnimalTameEvent test mod", version = "1.0", acceptableRemoteVersions = "*")
//@Mod.EventBusSubscriber
public class AnimalTameEventTest
{
static final String MOD_ID = "animal_tame_event_test";
static final boolean ENABLED = false;
@SubscribeEvent
public static void onAnimalTame(AnimalTameEvent event)
{
if (!ENABLED)
{
return;
}
if (event.getAnimal() instanceof EntityWolf)
{
event.setCanceled(true);
}
}
}
*/

View File

@ -1,56 +0,0 @@
/*
* Minecraft Forge
* Copyright (c) 2016-2019.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation version 2.1
* of the License.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
/*
package net.minecraftforge.debug.entity.living;
import net.minecraft.util.DamageSource;
import net.minecraftforge.event.entity.living.LivingAttackEvent;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.Mod.EventBusSubscriber;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
//@Mod(modid = AttackEventTest.MODID, name = AttackEventTest.NAME, version = "1.0.0", acceptableRemoteVersions = "*")
public class AttackEventTest
{
public static final String MODID = "livingattackeventtest";
public static final String NAME = "LivingAttackEventTest";
private static final Logger LOGGER = LogManager.getLogger(NAME);
//@EventBusSubscriber
public static class LivingAttackEventHandler
{
@SubscribeEvent
public static void onLivingAttack(LivingAttackEvent event)
{
if (event.getSource() == DamageSource.ANVIL)
{
LOGGER.info("{} was hit by an anvil!", event.getEntityLiving().getName());
}
}
}
}
*/

View File

@ -1,53 +0,0 @@
/*
* Minecraft Forge
* Copyright (c) 2016-2019.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation version 2.1
* of the License.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
/*
package net.minecraftforge.debug.entity.living;
import net.minecraft.entity.passive.EntityCow;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.entity.living.BabyEntitySpawnEvent;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.event.FMLPreInitializationEvent;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
//@Mod(modid = BabyEntitySpawnEventTest.MODID, name = "BreedingTest", version = "1.0", acceptableRemoteVersions = "*")
public class BabyEntitySpawnEventTest
{
public static final String MODID = "breedingtest";
static final boolean ENABLED = false;
@Mod.EventHandler
public void preInit(FMLPreInitializationEvent event)
{
if (ENABLED)
{
MinecraftForge.EVENT_BUS.register(this);
}
}
@SubscribeEvent
public void onBabyBorn(BabyEntitySpawnEvent event)
{
event.setChild(new EntityCow(event.getParentA().world));
}
}
*/

View File

@ -1,54 +0,0 @@
/*
* Minecraft Forge
* Copyright (c) 2016-2019.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation version 2.1
* of the License.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
/*
package net.minecraftforge.debug.entity.living;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.entity.living.LivingSpawnEvent.CheckSpawn;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.Mod.EventHandler;
import net.minecraftforge.fml.event.FMLPreInitializationEvent;
import net.minecraftforge.fml.common.eventhandler.Event.Result;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
//@Mod(modid = CheckSpawnEventTest.MODID, name = "CheckSpawnTest", version = "1.0", acceptableRemoteVersions = "*")
public class CheckSpawnEventTest
{
public static final String MODID = "checkspawntest";
public static final boolean ENABLED = false;
@EventHandler
public void onPreInit(FMLPreInitializationEvent event)
{
if (ENABLED)
{
MinecraftForge.EVENT_BUS.register(this);
}
}
@SubscribeEvent
public void canMobSpawn(CheckSpawn event)
{
event.setResult(Result.DENY);
}
}
*/

View File

@ -1,50 +0,0 @@
/*
* Minecraft Forge
* Copyright (c) 2016-2019.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation version 2.1
* of the License.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
/*
package net.minecraftforge.debug.entity.living;
import net.minecraft.block.material.Material;
import net.minecraft.entity.EntityLiving;
import net.minecraft.entity.EntitySpawnPlacementRegistry;
import net.minecraft.entity.monster.EntityStray;
import net.minecraftforge.common.util.EnumHelper;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.event.FMLPreInitializationEvent;
//@Mod(modid = CustomSpawnPlacementTest.MOD_ID, name = "Custom SpawnPlacementType test mod", version = "1.0", acceptableRemoteVersions = "*")
public class CustomSpawnPlacementTest
{
static final String MOD_ID = "custom_spawn_placement_test";
static final boolean ENABLED = false;
static final EntityLiving.SpawnPlacementType CUSTOM = EnumHelper.addSpawnPlacementType("CUSTOM", (world, pos) -> world.getBlockState(pos.down()).getMaterial() == Material.ICE);
@Mod.EventHandler
public void preInit(FMLPreInitializationEvent event)
{
if (ENABLED)
{
// needs edit to EntitySpawnPlacementRegistry to work
EntitySpawnPlacementRegistry.setPlacementType(EntityStray.class, CUSTOM);
}
}
}
*/

View File

@ -1,175 +0,0 @@
/*
* Minecraft Forge
* Copyright (c) 2016-2019.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation version 2.1
* of the License.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
/*
package net.minecraftforge.debug.entity.living;
import com.google.common.collect.ImmutableMap;
import java.util.Collections;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import javax.annotation.Nullable;
import net.minecraft.command.CommandBase;
import net.minecraft.command.CommandException;
import net.minecraft.command.ICommandSender;
import net.minecraft.command.WrongUsageException;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.server.MinecraftServer;
import net.minecraft.util.DamageSource;
import net.minecraft.util.math.BlockPos;
import net.minecraftforge.event.entity.living.LivingDamageEvent;
import net.minecraftforge.event.entity.living.LivingHurtEvent;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.Mod.EventBusSubscriber;
import net.minecraftforge.fml.common.Mod.EventHandler;
import net.minecraftforge.fml.event.FMLPreInitializationEvent;
import net.minecraftforge.fml.event.FMLServerStartingEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import org.apache.logging.log4j.Logger;
//@Mod(modid = DamageEventTest.MODID, name = "ForgeDebugLivingDamage", version = "1.0", acceptableRemoteVersions = "*")
public class DamageEventTest
{
private static Logger logger;
public static final String MODID = "forgedebuglivingdamage";
private static final Map<String, DamageSource> DAMAGE_SOURCES = ImmutableMap.<String, DamageSource> builder()
.put("fire", DamageSource.IN_FIRE)
.put("lightning_bolt", DamageSource.LIGHTNING_BOLT)
.put("on_fire", DamageSource.ON_FIRE)
.put("lava", DamageSource.LAVA)
.put("hot_floor", DamageSource.HOT_FLOOR)
.put("in_wall", DamageSource.IN_WALL)
.put("cramming", DamageSource.CRAMMING)
.put("drown", DamageSource.DROWN)
.put("starve", DamageSource.STARVE)
.put("cactus", DamageSource.CACTUS)
.put("fall", DamageSource.FALL)
.put("fly_into_wall", DamageSource.FLY_INTO_WALL)
.put("out_of_world", DamageSource.OUT_OF_WORLD)
.put("generic", DamageSource.GENERIC)
.put("magic", DamageSource.MAGIC)
.put("wither", DamageSource.WITHER)
.put("anvil", DamageSource.ANVIL)
.put("falling_block", DamageSource.FALLING_BLOCK)
.put("dragon_breath", DamageSource.DRAGON_BREATH)
.put("fireworks", DamageSource.FIREWORKS)
.build();
private static class CommandDamage extends CommandBase
{
private static final String USAGE = "damage <selector> <source> <amount>";
@Override
public String getName()
{
return "damage";
}
@Override
public String getUsage(ICommandSender sender)
{
return USAGE;
}
@Override
public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException
{
if (args.length < 3)
{
throw new WrongUsageException(USAGE);
}
EntityLivingBase target = getEntity(server, sender, args[0], EntityLivingBase.class);
DamageSource damageSource = DAMAGE_SOURCES.get(args[1].toLowerCase(Locale.ROOT));
if (target == null || damageSource == null)
{
throw new WrongUsageException(USAGE);
}
float amount;
try
{
amount = Float.parseFloat(args[2]);
} catch (NumberFormatException e)
{
throw new WrongUsageException(USAGE);
}
target.attackEntityFrom(damageSource, amount);
}
@Override
public List<String> getTabCompletions(MinecraftServer server, ICommandSender sender, String[] args, @Nullable BlockPos targetPos)
{
if (args.length == 1)
{
return getListOfStringsMatchingLastWord(args, server.getOnlinePlayerNames());
} else if (args.length == 2)
{
return getListOfStringsMatchingLastWord(args, DAMAGE_SOURCES.keySet());
}
return Collections.emptyList();
}
@Override
public boolean isUsernameIndex(String[] args, int index)
{
return index == 0;
}
}
@EventHandler
public void preInit(FMLPreInitializationEvent event)
{
logger = event.getModLog();
}
@EventHandler
void serverStarting(FMLServerStartingEvent evt)
{
evt.registerServerCommand(new CommandDamage());
}
//@EventBusSubscriber
public static class TestEventHandler
{
@net.minecraftforge.eventbus.api.SubscribeEvent
public static void livingHurtPre(LivingHurtEvent evt)
{
logger.info("Entity {} damage from {} (pre-reduction): {}", evt.getEntity(), evt.getSource().getDamageType(), evt.getAmount());
}
@net.minecraftforge.eventbus.api.SubscribeEvent
public static void livingHurtPost(LivingDamageEvent evt)
{
logger.info("Entity {} damage from {} (post-reduction): {}", evt.getEntity(), evt.getSource().getDamageType(), evt.getAmount());
}
}
}
*/

View File

@ -1,62 +0,0 @@
/*
* Minecraft Forge
* Copyright (c) 2016-2019.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation version 2.1
* of the License.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
/*
package net.minecraftforge.debug.entity.living;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.entity.living.LivingEquipmentChangeEvent;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.event.FMLPreInitializationEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import org.apache.logging.log4j.Logger;
//@Mod(modid = "equipment_change_test", name = "Equipment Change Test", version = "1.0.0", acceptableRemoteVersions = "*")
public class EquipmentChangeEventTest
{
private static final boolean ENABLED = false;
private static Logger logger;
@Mod.EventHandler
public void preInit(FMLPreInitializationEvent event)
{
if (ENABLED)
{
logger = event.getModLog();
MinecraftForge.EVENT_BUS.register(this);
}
}
*/
/**
* the Method handling the {@link LivingEquipmentChangeEvent}
* Serverside only!
*//*
@SubscribeEvent
public void onEquipmentChange(LivingEquipmentChangeEvent event)
{
//a debug console print
logger.info("[Equipment-Change] {} changed their Equipment in {} from {} to {}", event.getEntity(), event.getSlot(), event.getFrom(), event.getTo());
}
}
*/

View File

@ -1,52 +0,0 @@
/*
* Minecraft Forge
* Copyright (c) 2016-2019.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation version 2.1
* of the License.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
/*
package net.minecraftforge.debug.entity.living;
import net.minecraft.entity.passive.EntityCow;
import net.minecraft.entity.passive.EntitySheep;
import net.minecraftforge.event.entity.living.LivingKnockBackEvent;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.eventbus.api.SubscribeEvent;
//@Mod(modid = "kbhtest", name = "Knock Back Hook Test", version = "1.0", acceptableRemoteVersions = "*")
//@Mod.EventBusSubscriber
public class KnockBackEventTest
{
private static final boolean ENABLED = false;
@net.minecraftforge.eventbus.api.SubscribeEvent
public static void onKnockBack(LivingKnockBackEvent event)
{
if(ENABLED)
{
if(event.getEntityLiving() instanceof EntitySheep)
{
event.setStrength(0.2F);
}
else if(event.getEntityLiving() instanceof EntityCow)
{
event.setCanceled(true);
}
}
}
}*/

View File

@ -1,55 +0,0 @@
/*
* Minecraft Forge
* Copyright (c) 2016-2019.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation version 2.1
* of the License.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
/*
package net.minecraftforge.debug.entity.living;
import net.minecraftforge.event.entity.EntityMobGriefingEvent;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.common.eventhandler.Event.Result;
//@Mod(modid = "entitymobgriefingeventtest", name = "EntityMobGriefingEventTest", version = "1.0", acceptableRemoteVersions = "*")
//@Mod.EventBusSubscriber
public class MobGriefingEventTest
{
private static final boolean ENABLED = false;
@SubscribeEvent
public static void onMobGriefing(EntityMobGriefingEvent event)
{
if (ENABLED)
{
String customName = event.getEntity().getCustomNameTag();
try
{
Result result = Result.valueOf(customName);
event.setResult(result);
}
catch (IllegalArgumentException iae)
{
// Thrown if the name tag did not match a result value, can be ignored and DEFAULT will still be used.
}
}
}
}
*/

View File

@ -1,50 +0,0 @@
/*
* Minecraft Forge
* Copyright (c) 2016-2019.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation version 2.1
* of the License.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
/*
package net.minecraftforge.debug.entity.living;
import net.minecraft.entity.monster.EntityPigZombie;
import net.minecraftforge.event.entity.living.LivingSpawnEvent;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
//@Mod(modid = SpecialSpawnTest.MOD_ID, name = "Special Spawn Test", version = "1.0", acceptableRemoteVersions = "*")
//@Mod.EventBusSubscriber(modid = SpecialSpawnTest.MOD_ID)
public class SpecialSpawnTest
{
static final String MOD_ID = "special_spawn_test";
static final boolean ENABLED = false;
@SubscribeEvent
public static void onSpecialSpawn(LivingSpawnEvent.SpecialSpawn event)
{
if (!ENABLED)
{
return;
}
if (event.getEntity() instanceof EntityPigZombie)
{
event.getEntity().setCustomNameTag("Called SpecialSpawn");
}
}
}*/

View File

@ -1,44 +0,0 @@
/*
* Minecraft Forge
* Copyright (c) 2016-2019.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation version 2.1
* of the License.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
/*
package net.minecraftforge.debug.entity.living;
import net.minecraftforge.event.RegistryEvent;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.Mod.EventBusSubscriber;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.registry.VillagerRegistry.VillagerCareer;
import net.minecraftforge.fml.common.registry.VillagerRegistry.VillagerProfession;
//@Mod(modid = "professiontest", name = "ProfessionTest2000", version = "1.0", acceptableRemoteVersions = "*")
//@EventBusSubscriber
public class VillagerProfessionTest
{
@SubscribeEvent
public static void registerVillagers(RegistryEvent.Register<VillagerProfession> event)
{
VillagerProfession profession = new VillagerProfession("professiontest:test_villager", "professiontest:textures/entity/test_villager.png", "professiontest:textures/entity/zombie_test_villager.png");
new VillagerCareer(profession, "professiontest:test_villager");
event.getRegistry().register(profession);
}
}
*/

View File

@ -1,25 +0,0 @@
/*
* Minecraft Forge
* Copyright (c) 2016-2019.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation version 2.1
* of the License.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
@ParametersAreNonnullByDefault
@MethodsReturnNonnullByDefault
package net.minecraftforge.debug.entity.living;
import javax.annotation.ParametersAreNonnullByDefault;
import mcp.MethodsReturnNonnullByDefault;

View File

@ -1,92 +0,0 @@
/*
* Minecraft Forge
* Copyright (c) 2016-2019.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation version 2.1
* of the License.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
/*
package net.minecraftforge.debug.entity.player;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.entity.player.CriticalHitEvent;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.Mod.EventHandler;
import net.minecraftforge.fml.event.FMLInitializationEvent;
import net.minecraftforge.fml.event.FMLPreInitializationEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.eventbus.api.Event.Result;
import org.apache.logging.log4j.Logger;
import net.minecraft.util.EnumHand;
import net.minecraft.item.ItemStack;
import net.minecraft.item.ItemSword;
//@Mod(modid = "criticalhiteventtest", name = "CriticalHitEventTest", version = "1.0.0", acceptableRemoteVersions = "*")
public class CriticalHitEventTest
{
public static final boolean ENABLE = false;
private Logger log;
@EventHandler
public void preInit(FMLPreInitializationEvent event)
{
log = event.getModLog();
}
@EventHandler
public void init(FMLInitializationEvent event)
{
if (ENABLE)
MinecraftForge.EVENT_BUS.register(this);
}
@SubscribeEvent
public void onCriticalHit(CriticalHitEvent event)
{
ItemStack itemstack = event.getEntityPlayer().getHeldItem(EnumHand.MAIN_HAND);
if(event.getDamageModifier()>1F)
{
log.info("By default this hit will be critical.");
}
else
{
log.info("By default this hit won't be critical.");
}
if (itemstack.getItem() instanceof ItemSword)
{
event.setResult(Result.ALLOW); //Every hit is Critical
log.info("This hit will be critical.");
}
else if (!itemstack.isEmpty())
{
event.setResult(Result.DENY);//No hit will be Critical
log.info("This hit wont be critical.");
}
else
{
event.setResult(Result.DEFAULT); //Vanilla Hits
}
log.info("{} got hit by {} with a damagemodifier of {}" , event.getTarget(), event.getEntityPlayer(), event.getDamageModifier());
event.setDamageModifier(2.0F);
log.info("The damagemodifier is changed to {}", event.getDamageModifier());
}
}
*/

View File

@ -1,69 +0,0 @@
/*
* Minecraft Forge
* Copyright (c) 2016-2019.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation version 2.1
* of the License.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
/*
package net.minecraftforge.debug.entity.player;
import java.util.UUID;
import net.minecraft.entity.SharedMonsterAttributes;
import net.minecraft.entity.ai.attributes.AttributeModifier;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.entity.living.LivingEvent.LivingUpdateEvent;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.Mod.EventHandler;
import net.minecraftforge.fml.event.FMLInitializationEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
//@Mod(modid = "playerdamagereworktest", name = "PlayerDamageReworkTest", version = "0.0.0", acceptableRemoteVersions = "*")
public class DamageReworkTest
{
private static final boolean ENABLE = false;
private static final UUID ARMOR_MODIFIER_UUID = UUID.fromString("23373DC8-1F3D-11E7-93AE-92361F002671");
private static final AttributeModifier mod = new AttributeModifier(ARMOR_MODIFIER_UUID, "Player Damage Rework Test", 20, 0);
@EventHandler
public void init(FMLInitializationEvent event)
{
if (ENABLE) MinecraftForge.EVENT_BUS.register(this);
}
@net.minecraftforge.eventbus.api.SubscribeEvent
public void checkForSneakEvent(LivingUpdateEvent event)
{
if (event.getEntityLiving() instanceof EntityPlayer)
{
EntityPlayer player = (EntityPlayer) event.getEntityLiving();
if (player.isSneaking())
{
if (!player.getEntityAttribute(SharedMonsterAttributes.ARMOR).hasModifier(mod))
{
player.getEntityAttribute(SharedMonsterAttributes.ARMOR).applyModifier(mod);
}
}
else if (player.getEntityAttribute(SharedMonsterAttributes.ARMOR).hasModifier(mod))
{
player.getEntityAttribute(SharedMonsterAttributes.ARMOR).removeModifier(ARMOR_MODIFIER_UUID);
}
}
}
}*/

View File

@ -1,60 +0,0 @@
/*
* Minecraft Forge
* Copyright (c) 2016-2019.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation version 2.1
* of the License.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
/*
package net.minecraftforge.debug.entity.player;
import org.apache.logging.log4j.Logger;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.Mod.EventHandler;
import net.minecraftforge.fml.event.FMLPreInitializationEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.gameevent.PlayerEvent;
//@Mod(modid = ItemPickupEventTest.MODID, name = ItemPickupEventTest.NAME, version = ItemPickupEventTest.VERSION, acceptableRemoteVersions = "*")
public class ItemPickupEventTest
{
private static final boolean ENABLED = true;
public static final String MODID = "playeritempickupeventdebug";
public static final String NAME = "Player.ItemPickup Event Debug";
public static final String VERSION = "1.0.0";
private static Logger logger;
@EventHandler
public void init(FMLPreInitializationEvent event)
{
logger = event.getModLog();
if (ENABLED)
{
MinecraftForge.EVENT_BUS.register(this);
}
}
@SubscribeEvent
public void itemPickupEvent(PlayerEvent.ItemPickupEvent event)
{
logger.info("Item picked up: " + event.getStack().getDisplayName() + "x" + event.getStack().getCount());
}
}
*/

View File

@ -1,254 +0,0 @@
/*
* Minecraft Forge
* Copyright (c) 2016-2019.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation version 2.1
* of the License.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
/*
package net.minecraftforge.debug.entity.player;
import net.minecraft.entity.item.EntityArmorStand;
import net.minecraft.entity.monster.EntitySkeleton;
import net.minecraft.entity.passive.EntityHorse;
import net.minecraft.init.Items;
import net.minecraft.item.ItemBlock;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.tileentity.TileEntityChest;
import net.minecraft.tileentity.TileEntityDropper;
import net.minecraft.util.EnumActionResult;
import net.minecraft.util.EnumHand;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.entity.player.PlayerInteractEvent;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.Mod.EventHandler;
import net.minecraftforge.fml.event.FMLPreInitializationEvent;
import net.minecraftforge.eventbus.api.Event;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import org.apache.logging.log4j.Logger;
//@Mod(modid = "playerinteracteventtest", name = "PlayerInteractEventTest", version = "0.0.0", acceptableRemoteVersions = "*")
public class PlayerInteractEventTest
{
// NOTE: Test with both this ON and OFF - ensure none of the test behaviours show when this is off!
private static final boolean ENABLE = false;
private static Logger logger;
@EventHandler
public void preinit(FMLPreInitializationEvent event)
{
logger = event.getModLog();
MinecraftForge.EVENT_BUS.register(this);
MinecraftForge.EVENT_BUS.register(PlayerInteractEventTest.class); // Test Static event listeners
}
@net.minecraftforge.eventbus.api.SubscribeEvent(receiveCanceled = true) // this triggers after the subclasses below, and we'd like to log them all
public void global(PlayerInteractEvent evt)
{
if (!ENABLE)
{
return;
}
logger.info("{} | {}", evt.getClass().getSimpleName(), evt.getSide().name());
logger.info("{} | stack: {}", evt.getHand(), evt.getItemStack());
logger.info("{} | face: {}", evt.getPos(), evt.getFace());
}
@net.minecraftforge.eventbus.api.SubscribeEvent
public void leftClickBlock(PlayerInteractEvent.LeftClickBlock evt)
{
if (!ENABLE)
{
return;
}
logger.info("HIT VEC: {}", evt.getHitVec());
if (!evt.getItemStack().isEmpty())
{
if (evt.getItemStack().getItem() == Items.GOLDEN_PICKAXE)
{
evt.setCanceled(true); // Redstone should not activate and pick should not be able to dig anything
}
if (evt.getItemStack().getItem() == Items.DIAMOND_PICKAXE)
{
evt.setUseBlock(net.minecraftforge.eventbus.api.Event.Result.DENY); // Redstone should not activate, pick should still dig
}
if (evt.getItemStack().getItem() == Items.IRON_PICKAXE)
{
evt.setUseItem(Event.Result.DENY); // Pick should not dig, Redstone should still activate
}
}
// When item use denied, the event will keep firing as long as the left click button is held.
// This is due to how vanilla calls the left click handling methods to let people not lift their button when mining multiple blocks.
// Note that when item use is denied, the cool down for the item does not occur. This is good!
}
@SubscribeEvent
public void rightClickBlock(PlayerInteractEvent.RightClickBlock evt)
{
if (!ENABLE)
{
return;
}
logger.info("HIT VEC: {}", evt.getHitVec());
// Shift right clicking dropper with an item in hand should still open the dropper contrary to normal mechanics
// The item in hand is used as well (not specifying anything would not use the item)
TileEntity te = evt.getWorld().getTileEntity(evt.getPos());
if (te instanceof TileEntityDropper)
{
evt.setUseBlock(net.minecraftforge.eventbus.api.Event.Result.ALLOW);
evt.setUseItem(Event.Result.ALLOW);
}
// Same as above, except the item should no longer be used
if (te instanceof TileEntityChest)
{
evt.setUseBlock(net.minecraftforge.eventbus.api.Event.Result.ALLOW);
evt.setUseItem(net.minecraftforge.eventbus.api.Event.Result.DENY); // could be left out as well
}
// Case: Flint and steel in main hand on top of a TE will light a fire, not open the TE.
// Note that if you do this on a chest, the f+s will fail, but then your off hand will open the chest
// If you dual wield flints and steels and right click a chest nothing should happen
if (!evt.getItemStack().isEmpty() && evt.getItemStack().getItem() == Items.FLINT_AND_STEEL)
{
evt.setUseBlock(net.minecraftforge.eventbus.api.Event.Result.DENY);
}
// Case: Painting in main hand
// Opening a TE will also place a painting on the TE if possible
if (evt.getHand() == EnumHand.MAIN_HAND && !evt.getItemStack().isEmpty() && evt.getItemStack().getItem() == Items.PAINTING)
{
evt.setUseItem(net.minecraftforge.eventbus.api.Event.Result.ALLOW);
}
// Spawn egg in main hand, block in offhand -> block should be placed
if (!evt.getItemStack().isEmpty()
&& evt.getItemStack().getItem() == Items.SPAWN_EGG
&& evt.getHand() == EnumHand.MAIN_HAND
&& !evt.getEntityPlayer().getHeldItemOffhand().isEmpty()
&& evt.getEntityPlayer().getHeldItemOffhand().getItem() instanceof ItemBlock)
{
evt.setCanceled(true);
}
// Spawn egg in main hand, potion in offhand -> potion should NOT be thrown
if (!evt.getItemStack().isEmpty()
&& evt.getItemStack().getItem() == Items.SPAWN_EGG
&& evt.getHand() == EnumHand.MAIN_HAND
&& !evt.getEntityPlayer().getHeldItemOffhand().isEmpty()
&& evt.getEntityPlayer().getHeldItemOffhand().getItem() == Items.SPLASH_POTION)
{
evt.setCanceled(true);
// Fake spawn egg success so splash potion does not trigger
evt.setCancellationResult(EnumActionResult.SUCCESS);
}
}
@SubscribeEvent
public void rightClickItem(PlayerInteractEvent.RightClickItem evt)
{
if (!ENABLE)
{
return;
}
// Case: Ender pearl in main hand, block in offhand -> Block is NOT placed
if (!evt.getItemStack().isEmpty()
&& evt.getItemStack().getItem() == Items.ENDER_PEARL
&& evt.getHand() == EnumHand.MAIN_HAND
&& !evt.getEntityPlayer().getHeldItemOffhand().isEmpty()
&& evt.getEntityPlayer().getHeldItemOffhand().getItem() instanceof ItemBlock)
{
evt.setCanceled(true);
evt.setCancellationResult(EnumActionResult.SUCCESS); // We fake success on the ender pearl so block is not placed
return;
}
// Case: Ender pearl in main hand, bow in offhand with arrows in inv -> Bow should trigger
// Case: Sword in main hand, ender pearl in offhand -> Nothing should happen
if (!evt.getItemStack().isEmpty() && evt.getItemStack().getItem() == Items.ENDER_PEARL)
{
evt.setCanceled(true);
}
}
@SubscribeEvent
public void interactSpecific(PlayerInteractEvent.EntityInteractSpecific evt)
{
if (!ENABLE)
{
return;
}
logger.info("LOCAL POS: {}", evt.getLocalPos());
if (!evt.getItemStack().isEmpty()
&& evt.getTarget() instanceof EntityArmorStand
&& evt.getItemStack().getItem() == Items.IRON_HELMET)
{
evt.setCanceled(true); // Should not be able to place iron helmet onto armor stand (you will put it on instead)
}
if (!evt.getItemStack().isEmpty()
&& evt.getTarget() instanceof EntityArmorStand
&& evt.getItemStack().getItem() == Items.GOLDEN_HELMET)
{
evt.setCanceled(true);
evt.setCancellationResult(EnumActionResult.SUCCESS);
// Should not be able to place golden helmet onto armor stand
// However you will NOT put it on because we fake success on the armorstand.
}
if (!evt.getWorld().isRemote
&& evt.getTarget() instanceof EntitySkeleton
&& evt.getLocalPos().y > evt.getTarget().height / 2.0)
{
// If we right click the upper half of a skeleton it dies.
evt.getTarget().setDead();
evt.setCanceled(true);
}
}
@SubscribeEvent
public static void interactNormal(PlayerInteractEvent.EntityInteract evt)
{
if (!ENABLE)
{
return;
}
if (!evt.getItemStack().isEmpty() && evt.getTarget() instanceof EntityHorse)
{
// Should not be able to feed wild horses with golden apple (you will start eating it in survival)
if (evt.getItemStack().getItem() == Items.GOLDEN_APPLE
&& evt.getItemStack().getItemDamage() == 0)
{
evt.setCanceled(true);
}
// Should not be able to feed wild horses with notch apple but you will NOT eat it
if (evt.getItemStack().getItem() == Items.GOLDEN_APPLE
&& evt.getItemStack().getItemDamage() == 1)
{
evt.setCanceled(true);
evt.setCancellationResult(EnumActionResult.SUCCESS);
}
}
}
}
*/

View File

@ -1,56 +0,0 @@
/*
* Minecraft Forge
* Copyright (c) 2016-2019.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation version 2.1
* of the License.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
/*
package net.minecraftforge.debug.entity.player;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.entity.player.PlayerSetSpawnEvent;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.Mod.EventHandler;
import net.minecraftforge.fml.event.FMLPreInitializationEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import org.apache.logging.log4j.Logger;
//@Mod(modid = "playersetspawntest", name = "Player Set Spawn Test", version = "0.0.0", acceptableRemoteVersions = "*")
public class PlayerSetSpawnTest
{
private static final boolean ENABLE = false;
private static Logger logger;
@EventHandler
public void preInit(FMLPreInitializationEvent event)
{
if (ENABLE)
{
logger = event.getModLog();
MinecraftForge.EVENT_BUS.register(this);
}
}
@SubscribeEvent
public void onPlayerSetSpawn(PlayerSetSpawnEvent event)
{
logger.info("{} {}", event.isForced(), event.getNewSpawn().toString());
event.setCanceled(true);
}
}
*/

View File

@ -1,84 +0,0 @@
/*
* Minecraft Forge
* Copyright (c) 2016-2019.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation version 2.1
* of the License.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
/*
package net.minecraftforge.debug.entity.player;
import com.google.common.collect.Multimap;
import net.minecraft.client.renderer.model.ModelResourceLocation;
import net.minecraft.entity.ai.attributes.AttributeModifier;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.EntityEquipmentSlot;
import net.minecraft.item.Item;
import net.minecraft.item.ItemArmor;
import net.minecraft.item.ItemStack;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.client.event.ModelRegistryEvent;
import net.minecraftforge.client.model.ModelLoader;
import net.minecraftforge.event.RegistryEvent;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.eventbus.api.SubscribeEvent;
//@Mod(modid = ReachDistanceAttributeTest.MODID, name = ReachDistanceAttributeTest.MODID, version = "1.0", acceptableRemoteVersions = "*")
//@Mod.EventBusSubscriber
public class ReachDistanceAttributeTest
{
public static final String MODID = "reachdistanceattributetest";
private static final Item PLATE = new ExtendedReachPlate().setRegistryName(MODID, "extended_reach_plate");
@SubscribeEvent
public static void registerItems(RegistryEvent.Register<Item> evt) {
evt.getRegistry().register(PLATE);
}
//@Mod.EventBusSubscriber(Side.CLIENT)
public static class ClientEvents
{
@net.minecraftforge.eventbus.api.SubscribeEvent
public static void registerModels(ModelRegistryEvent evt)
{
ModelLoader.setCustomModelResourceLocation(PLATE, 0, new ModelResourceLocation("minecraft:diamond_chestplate", "inventory"));
}
}
public static class ExtendedReachPlate extends ItemArmor
{
private static final AttributeModifier BOOST = new AttributeModifier("extended reach plate boost", 3, 0);
public ExtendedReachPlate()
{
super(ArmorMaterial.DIAMOND, 3, EntityEquipmentSlot.CHEST);
setUnlocalizedName("extendedReachPlate");
}
@Override
public Multimap<String, AttributeModifier> getAttributeModifiers(EntityEquipmentSlot slot, ItemStack stack)
{
Multimap<String, AttributeModifier> attribs = super.getAttributeModifiers(slot, stack);
if (slot == this.armorType)
{
attribs.put(EntityPlayer.REACH_DISTANCE.getName(), BOOST);
}
return attribs;
}
}
}
*/

View File

@ -1,84 +0,0 @@
/*
* Minecraft Forge
* Copyright (c) 2016-2019.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation version 2.1
* of the License.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
/*
package net.minecraftforge.debug.entity.player;
import com.google.common.collect.Multimap;
import net.minecraft.client.renderer.model.ModelResourceLocation;
import net.minecraft.entity.ai.attributes.AttributeModifier;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.inventory.EntityEquipmentSlot;
import net.minecraft.item.Item;
import net.minecraft.item.ItemArmor;
import net.minecraft.item.ItemStack;
import net.minecraftforge.client.event.ModelRegistryEvent;
import net.minecraftforge.client.model.ModelLoader;
import net.minecraftforge.event.RegistryEvent;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.relauncher.Side;
//@Mod(modid = SwimSpeedAttributeTest.MODID, name = SwimSpeedAttributeTest.MODID, version = "1.0", acceptableRemoteVersions = "*")
//@Mod.EventBusSubscriber
public class SwimSpeedAttributeTest
{
public static final String MODID = "swimspeedattributetest";
private static final Item PLATE = new SwimSpeedPlate().setRegistryName(MODID, "swim_speed_plate");
@SubscribeEvent
public static void registerItems(RegistryEvent.Register<Item> evt) {
evt.getRegistry().register(PLATE);
}
//@Mod.EventBusSubscriber(Side.CLIENT)
public static class ClientEvents
{
@SubscribeEvent
public static void registerModels(ModelRegistryEvent evt)
{
ModelLoader.setCustomModelResourceLocation(PLATE, 0, new ModelResourceLocation("minecraft:diamond_chestplate", "inventory"));
}
}
public static class SwimSpeedPlate extends ItemArmor
{
private static final AttributeModifier BOOST = new AttributeModifier("swim speed plate boost", 3, 0);
public SwimSpeedPlate()
{
super(ArmorMaterial.DIAMOND, 3, EntityEquipmentSlot.CHEST);
setUnlocalizedName("swimSpeedPlate");
}
@Override
public Multimap<String, AttributeModifier> getAttributeModifiers(EntityEquipmentSlot slot, ItemStack stack)
{
Multimap<String, AttributeModifier> attribs = super.getAttributeModifiers(slot, stack);
if (slot == this.armorType)
{
attribs.put(EntityLivingBase.SWIM_SPEED.getName(), BOOST);
}
return attribs;
}
}
}
*/

View File

@ -1,79 +0,0 @@
/*
* Minecraft Forge
* Copyright (c) 2016-2019.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation version 2.1
* of the License.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
/*
package net.minecraftforge.debug.fluid;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.event.RegistryEvent;
import net.minecraftforge.fluids.BlockFluidBase;
import net.minecraftforge.fluids.BlockFluidClassic;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidRegistry;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.Mod.EventBusSubscriber;
import net.minecraftforge.fml.common.Mod.EventHandler;
import net.minecraftforge.fml.event.FMLPreInitializationEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.registry.GameRegistry.ObjectHolder;
//@Mod(modid = ColoredFluidTest.MODID, name = "Test Mod", version = "1.0.0", acceptedMinecraftVersions = "*", acceptableRemoteVersions = "*")
//@EventBusSubscriber
public class ColoredFluidTest
{
static final boolean ENABLED = false; // <-- enable mod
static final int COLOR = 0xFFAFAF; // <-- change this to try other colors
static final String MODID = "fluidadditionalfields";
static final ResourceLocation RES_LOC = new ResourceLocation(MODID, "slime");
static
{
if (ENABLED)
{
FluidRegistry.enableUniversalBucket();
}
}
public static final Fluid SLIME = new Fluid("slime", new ResourceLocation(MODID, "slime_still"), new ResourceLocation(MODID, "slime_flow"), new ResourceLocation(MODID, "slime_overlay")).setColor(COLOR);
@ObjectHolder("slime")
public static final BlockFluidBase SLIME_BLOCK = null;
@EventHandler
public void preInit(FMLPreInitializationEvent event)
{
if (ENABLED)
{
FluidRegistry.registerFluid(SLIME);
FluidRegistry.addBucketForFluid(SLIME);
}
}
@SubscribeEvent
public static void eventBlockRegistry(final RegistryEvent.Register<Block> event)
{
if (ENABLED)
{
event.getRegistry().register((new BlockFluidClassic(SLIME, Material.WATER)).setRegistryName(RES_LOC).setUnlocalizedName(RES_LOC.toString()));
}
}
}
*/

View File

@ -1,61 +0,0 @@
/*
* Minecraft Forge
* Copyright (c) 2016-2019.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation version 2.1
* of the License.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
/*
package net.minecraftforge.debug.fluid;
import net.minecraft.init.Blocks;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.world.BlockEvent.CreateFluidSourceEvent;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.event.FMLInitializationEvent;
import net.minecraftforge.eventbus.api.Event.Result;
import net.minecraftforge.eventbus.api.SubscribeEvent;
//@Mod(modid = "createfluidsourcetest", name = "CreateFluidSourceTest", version = "1.0", acceptableRemoteVersions = "*")
public class CreateFluidSourceEventTest
{
public static final boolean ENABLE = false;
@Mod.EventHandler
public static void init(FMLInitializationEvent event)
{
if (ENABLE)
{
MinecraftForge.EVENT_BUS.register(CreateFluidSourceEventTest.class);
}
}
@net.minecraftforge.eventbus.api.SubscribeEvent
public static void onCreateFluidSource(CreateFluidSourceEvent event)
{
// make it work exactly the opposite of how it works by default
if (event.getState().getBlock() == Blocks.FLOWING_WATER)
{
event.setResult(Result.DENY);
}
else
{
event.setResult(Result.ALLOW);
}
}
}
*/

View File

@ -1,386 +0,0 @@
/*
* Minecraft Forge
* Copyright (c) 2016-2019.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation version 2.1
* of the License.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
/*
package net.minecraftforge.debug.fluid;
import net.minecraft.block.Block;
import net.minecraft.block.BlockContainer;
import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.renderer.ItemMeshDefinition;
import net.minecraft.client.renderer.model.ModelBakery;
import net.minecraft.client.renderer.model.ModelResourceLocation;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.IRecipe;
import net.minecraft.item.crafting.Ingredient;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.network.NetworkManager;
import net.minecraft.network.play.server.SPacketUpdateTileEntity;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ActionResult;
import net.minecraft.util.EnumActionResult;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumHand;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.RayTraceResult;
import net.minecraft.util.text.TextComponentString;
import net.minecraft.world.World;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.client.event.ModelRegistryEvent;
import net.minecraftforge.client.model.ModelLoader;
import net.minecraftforge.common.ForgeVersion;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.common.capabilities.Capability;
import net.minecraftforge.debug.client.model.ModelFluidTest;
import net.minecraftforge.debug.client.model.ModelFluidTest.TestFluid;
import net.minecraftforge.debug.client.model.ModelFluidTest.TestGas;
import net.minecraftforge.event.RegistryEvent;
import net.minecraftforge.event.entity.player.FillBucketEvent;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidRegistry;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.FluidTankOld;
import net.minecraftforge.fluids.FluidUtil;
import net.minecraftforge.fluids.IFluidBlock;
import net.minecraftforge.fluids.UniversalBucket;
import net.minecraftforge.fluids.capability.CapabilityFluidHandler;
import net.minecraftforge.fluids.capability.IFluidHandler;
import net.minecraftforge.fluids.capability.IFluidHandlerItem;
import net.minecraftforge.fluids.capability.IFluidTankProperties;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.Mod.EventHandler;
import net.minecraftforge.fml.event.FMLPreInitializationEvent;
import net.minecraftforge.eventbus.api.Event.Result;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.registry.GameRegistry;
import net.minecraftforge.fml.common.registry.GameRegistry.ObjectHolder;
import net.minecraftforge.items.IItemHandler;
import net.minecraftforge.items.ItemStackHandler;
import net.minecraftforge.items.wrapper.CombinedInvWrapper;
import org.apache.logging.log4j.Logger;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
//@Mod(modid = DynBucketTest.MODID, name = "DynBucketTest", version = "0.1", dependencies = "after:" + ModelFluidTest.MODID, acceptableRemoteVersions = "*")
public class DynBucketTest
{
public static final String MODID = "dynbuckettest";
private static final ResourceLocation simpleTankName = new ResourceLocation(MODID, "simpletank");
private static final ResourceLocation testItemName = new ResourceLocation(MODID, "testitem");
private static final boolean ENABLE = false;
private static Logger logger;
@ObjectHolder("testitem")
public static final Item TEST_ITEM = null;
@ObjectHolder("simpletank")
public static final Block TANK_BLOCK = null;
@ObjectHolder("simpletank")
public static final Item TANK_ITEM = null;
@ObjectHolder("dynbottle")
public static final Item DYN_BOTTLE = null;
static
{
if (ENABLE && ModelFluidTest.ENABLE)
{
FluidRegistry.enableUniversalBucket();
}
}
@SubscribeEvent
public void registerBlocks(RegistryEvent.Register<Block> event)
{
event.getRegistry().register(new BlockSimpleTank().setRegistryName(simpleTankName));
GameRegistry.registerTileEntity(TileSimpleTank.class, "simpletank");
}
@net.minecraftforge.eventbus.api.SubscribeEvent
public void registerItems(RegistryEvent.Register<Item> event)
{
FluidRegistry.addBucketForFluid(FluidRegistry.getFluid(TestFluid.name));
FluidRegistry.addBucketForFluid(FluidRegistry.getFluid(TestGas.name));
event.getRegistry().registerAll(
new TestItem().setRegistryName(testItemName),
new ItemBlock(TANK_BLOCK).setRegistryName(simpleTankName),
new DynBottle()
);
}
@net.minecraftforge.eventbus.api.SubscribeEvent
public void registerRecipes(RegistryEvent.Register<IRecipe> event)
{
ItemStack filledBucket = FluidUtil.getFilledBucket(new FluidStack(ModelFluidTest.FLUID, FluidAttributes.BUCKET_VOLUME));
GameRegistry.addShapelessRecipe(new ResourceLocation(MODID, "diamond_to_fluid"), null, filledBucket, Ingredient.fromItem(Items.DIAMOND));
}
@SuppressWarnings("unused")
@EventHandler
public void preInit(FMLPreInitializationEvent event)
{
logger = event.getModLog();
if (ENABLE && ModelFluidTest.ENABLE)
{
MinecraftForge.EVENT_BUS.register(this);
}
}
@net.minecraftforge.eventbus.api.SubscribeEvent
public void onBucketFill(FillBucketEvent event)
{
RayTraceResult target = event.getTarget();
if (target != null)
{
IBlockState state = event.getWorld().getBlockState(target.getBlockPos());
if (state.getBlock() instanceof IFluidBlock)
{
Fluid fluid = ((IFluidBlock) state.getBlock()).getFluid();
FluidStack fs = new FluidStack(fluid, FluidAttributes.BUCKET_VOLUME);
ItemStack bucket = event.getEmptyBucket();
IFluidHandlerItem fluidHandler = FluidUtil.getFluidHandler(bucket);
if (fluidHandler != null)
{
int fillAmount = fluidHandler.fill(fs, true);
if (fillAmount > 0)
{
ItemStack filledBucket = fluidHandler.getContainer();
event.setFilledBucket(filledBucket);
event.setResult(Result.ALLOW);
}
}
}
}
}
//@Mod.EventBusSubscriber(value = Side.CLIENT, modid = MODID)
public static class ClientEventHandler
{
@net.minecraftforge.eventbus.api.SubscribeEvent
public static void setupModels(ModelRegistryEvent event)
{
if (!ENABLE || !ModelFluidTest.ENABLE) return;
ModelLoader.setBucketModelDefinition(DYN_BOTTLE);
final ModelResourceLocation bottle = new ModelResourceLocation(new ResourceLocation(ForgeVersion.MOD_ID, "dynbottle"), "inventory");
ModelLoader.setCustomMeshDefinition(DYN_BOTTLE, new ItemMeshDefinition()
{
@Override
public ModelResourceLocation getModelLocation(@Nonnull ItemStack stack)
{
return bottle;
}
});
ModelBakery.registerItemVariants(DYN_BOTTLE, bottle);
ModelLoader.setCustomModelResourceLocation(Item.REGISTRY.getObject(simpleTankName), 0, new ModelResourceLocation(simpleTankName, "normal"));
ModelLoader.setCustomModelResourceLocation(Item.REGISTRY.getObject(testItemName), 0, new ModelResourceLocation(new ResourceLocation("minecraft", "stick"), "inventory"));
}
}
public static class TestItem extends Item
{
@Override
public ActionResult<ItemStack> onItemRightClick(World worldIn, EntityPlayer playerIn, EnumHand hand)
{
ItemStack itemStackIn = playerIn.getHeldItem(hand);
if (worldIn.isRemote)
{
return new ActionResult<ItemStack>(EnumActionResult.PASS, itemStackIn);
}
ItemStackHandler handler = new ItemStackHandler(5);
ItemStackHandler handler2 = new ItemStackHandler(5);
IItemHandler joined = new CombinedInvWrapper(handler, handler2);
handler.setStackInSlot(0, new ItemStack(Blocks.STONE));
handler.setStackInSlot(1, new ItemStack(Blocks.GRASS));
handler.setStackInSlot(2, new ItemStack(Blocks.DIRT));
handler.setStackInSlot(3, new ItemStack(Blocks.GLASS));
handler.setStackInSlot(4, new ItemStack(Blocks.SAND));
handler2.setStackInSlot(0, new ItemStack(Blocks.SLIME_BLOCK));
handler2.setStackInSlot(1, new ItemStack(Blocks.TNT));
handler2.setStackInSlot(2, new ItemStack(Blocks.PLANKS));
handler2.setStackInSlot(3, new ItemStack(Blocks.LOG));
handler2.setStackInSlot(4, new ItemStack(Blocks.DIAMOND_BLOCK));
for (int i = 0; i < handler.getSlots(); i++)
{
logger.info("Expected 1: {}", handler.getStackInSlot(i));
}
for (int i = 0; i < handler2.getSlots(); i++)
{
logger.info("Expected 2: {}", handler2.getStackInSlot(i));
}
for (int i = 0; i < joined.getSlots(); i++)
{
logger.info("Joined: {}", joined.getStackInSlot(i));
}
return new ActionResult<ItemStack>(EnumActionResult.SUCCESS, itemStackIn);
}
}
public static class DynBottle extends UniversalBucket
{
public DynBottle()
{
super(250, new ItemStack(Items.GLASS_BOTTLE), true);
setUnlocalizedName("dynbottle");
setRegistryName(new ResourceLocation(MODID, "dynbottle"));
setMaxStackSize(16);
setHasSubtypes(true);
setCreativeTab(CreativeTabs.MISC);
}
}
// simple tank copied from tinkers construct
public static class BlockSimpleTank extends BlockContainer
{
protected BlockSimpleTank()
{
super(Material.ROCK);
setCreativeTab(CreativeTabs.MISC);
}
@Override
public TileEntity createNewTileEntity(World worldIn, int meta)
{
return new TileSimpleTank();
}
@Override
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ)
{
ItemStack heldItem = playerIn.getHeldItem(hand);
IFluidHandler tank = FluidUtil.getFluidHandler(worldIn, pos, side.getOpposite());
if (tank == null)
{
return false;
}
if (heldItem.isEmpty())
{
sendText(playerIn, tank);
return false;
}
// do the thing with the tank and the buckets
if (FluidUtil.interactWithFluidHandler(playerIn, hand, worldIn, pos, side))
{
return true;
}
else
{
sendText(playerIn, tank);
}
// prevent interaction of the item if it's a fluidcontainer. Prevents placing liquids when interacting with the tank
return FluidUtil.getFluidHandler(heldItem) != null;
}
private void sendText(EntityPlayer player, IFluidHandler tank)
{
if (player.world.isRemote)
{
String text;
IFluidTankProperties[] tankProperties = tank.getTankProperties();
if (tankProperties.length > 0 && tankProperties[0] != null && tankProperties[0].getContents() != null)
{
text = tankProperties[0].getContents().amount + "x " + tankProperties[0].getContents().getLocalizedName();
}
else
{
text = "empty";
}
player.sendMessage(new TextComponentString(text));
}
}
}
public static class TileSimpleTank extends TileEntity
{
FluidTankOld tank = new FluidTankOld(4000);
@Override
public void readFromNBT(NBTTagCompound tags)
{
super.readFromNBT(tags);
tank.readFromNBT(tags);
}
@Override
public NBTTagCompound writeToNBT(NBTTagCompound tags)
{
tags = super.writeToNBT(tags);
tank.writeToNBT(tags);
return tags;
}
@Override
public SPacketUpdateTileEntity getUpdatePacket()
{
NBTTagCompound tag = new NBTTagCompound();
tag = writeToNBT(tag);
return new SPacketUpdateTileEntity(this.getPos(), this.getBlockMetadata(), tag);
}
@Override
public void onDataPacket(NetworkManager net, SPacketUpdateTileEntity pkt)
{
super.onDataPacket(net, pkt);
readFromNBT(pkt.getNbtCompound());
}
@Override
public boolean hasCapability(@Nonnull Capability<?> capability, @Nullable EnumFacing facing)
{
return capability == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY || super.hasCapability(capability, facing);
}
@Override
@Nullable
public <T> T getCapability(@Nonnull Capability<T> capability, @Nullable EnumFacing facing)
{
if (capability == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY)
{
return CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY.cast(tank);
}
return super.getCapability(capability, facing);
}
}
}
*/

View File

@ -1,70 +0,0 @@
/*
* Minecraft Forge
* Copyright (c) 2016-2019.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation version 2.1
* of the License.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
/*
package net.minecraftforge.debug.fluid;
import net.minecraft.block.BlockStone;
import net.minecraft.init.Blocks;
import net.minecraft.world.biome.Biome;
import net.minecraft.world.biome.BiomeHills;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.world.BlockEvent;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.event.FMLPreInitializationEvent;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
*/
/**
* This test will:
* - Cause lava to turn into gold when touched by water.
* - Replace the result of a cobblestone generator with granite.
* - Replace the result of a stone generator with either diamond, or emerald when in a biome where emerald spawns naturally.
* - Prevent lava from setting surrounding blocks on fire.
*//*
//@Mod(modid = "fluidplaceblocktest", name = "FluidPlaceBlockTest", version = "0.0.0", acceptableRemoteVersions = "*")
public class FluidPlaceBlockEventTest
{
private static final boolean ENABLED = false;
@Mod.EventHandler
public void preinit(FMLPreInitializationEvent event)
{
if (!ENABLED) return;
MinecraftForge.EVENT_BUS.register(FluidPlaceBlockEventTest.class);
}
@SubscribeEvent @SuppressWarnings("unused")
public static void onFluidPlaceBlockEvent(BlockEvent.FluidPlaceBlockEvent event)
{
if (event.getState().getBlock() == Blocks.OBSIDIAN) event.setNewState(Blocks.GOLD_BLOCK.getDefaultState());
if (event.getState().getBlock() == Blocks.COBBLESTONE) event.setNewState(Blocks.STONE.getDefaultState().withProperty(BlockStone.VARIANT, BlockStone.EnumType.GRANITE));
if (event.getState() == Blocks.STONE.getDefaultState())
{
Biome biome = event.getWorld().getBiome(event.getPos());
if (biome instanceof BiomeHills) event.setNewState(Blocks.EMERALD_BLOCK.getDefaultState());
else event.setNewState(Blocks.DIAMOND_BLOCK.getDefaultState());
}
if (event.getState().getBlock() == Blocks.FIRE) event.setNewState(event.getOriginalState());
}
}
*/

View File

@ -1,324 +0,0 @@
/*
* Minecraft Forge
* Copyright (c) 2016-2019.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation version 2.1
* of the License.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
/*
package net.minecraftforge.debug.fluid;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.renderer.model.ModelBakery;
import net.minecraft.client.renderer.model.ModelResourceLocation;
import net.minecraft.client.renderer.block.statemap.StateMapperBase;
import net.minecraft.client.util.ITooltipFlag;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.init.Blocks;
import net.minecraft.item.Item;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemBucket;
import net.minecraft.item.ItemBucketMilk;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.NonNullList;
import net.minecraft.util.ResourceLocation;
import net.minecraft.world.World;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.client.event.ModelRegistryEvent;
import net.minecraftforge.client.model.ModelLoader;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.common.capabilities.ICapabilityProvider;
import net.minecraftforge.debug.client.model.ModelFluidTest;
import net.minecraftforge.event.RegistryEvent;
import net.minecraftforge.fluids.BlockFluidBase;
import net.minecraftforge.fluids.BlockFluidFinite;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidRegistry;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.UniversalBucket;
import net.minecraftforge.fluids.capability.templates.FluidHandlerItemStack;
import net.minecraftforge.fluids.capability.wrappers.FluidBucketWrapper;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.api.distmarker.Dist;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.util.List;
import static net.minecraftforge.fluids.capability.templates.FluidHandlerItemStack.FLUID_NBT_KEY;
//@Mod(modid = FluidPlacementTest.MODID, name = "ForgeDebugFluidPlacement", version = FluidPlacementTest.VERSION, acceptableRemoteVersions = "*")
public class FluidPlacementTest
{
public static final String MODID = "forgedebugfluidplacement";
public static final String VERSION = "1.0";
public static final boolean ENABLE = true;
//@Mod.EventBusSubscriber(modid = MODID)
public static class Registration
{
@SubscribeEvent
public static void registerBlocks(RegistryEvent.Register<Block> event)
{
if (!ENABLE || !ModelFluidTest.ENABLE)
return;
event.getRegistry().registerAll(
FiniteFluidBlock.instance
);
}
@SubscribeEvent
public static void registerItems(RegistryEvent.Register<Item> event)
{
if (!ENABLE || !ModelFluidTest.ENABLE)
return;
FluidRegistry.registerFluid(FiniteFluid.instance);
FluidRegistry.addBucketForFluid(FiniteFluid.instance);
event.getRegistry().registerAll(
EmptyFluidContainer.instance,
FluidContainer.instance,
new FluidItemBlock(FiniteFluidBlock.instance).setRegistryName(FiniteFluidBlock.instance.getRegistryName())
);
MinecraftForge.EVENT_BUS.register(FluidContainer.instance);
}
}
//@Mod.EventBusSubscriber(value = Side.CLIENT, modid = MODID)
public static class ClientEventHandler
{
@SubscribeEvent
public static void registerModels(ModelRegistryEvent event)
{
if (!ENABLE || !ModelFluidTest.ENABLE)
return;
ModelResourceLocation fluidLocation = new ModelResourceLocation(MODID.toLowerCase() + ":" + FiniteFluidBlock.name, "normal");
Item fluid = Item.getItemFromBlock(FiniteFluidBlock.instance);
ModelLoader.setCustomModelResourceLocation(EmptyFluidContainer.instance, 0, new ModelResourceLocation("forge:bucket", "inventory"));
ModelLoader.setBucketModelDefinition(FluidContainer.instance);
// no need to pass the locations here, since they'll be loaded by the block model logic.
ModelBakery.registerItemVariants(fluid);
ModelLoader.setCustomMeshDefinition(fluid, stack -> fluidLocation);
ModelLoader.setCustomStateMapper(FiniteFluidBlock.instance, new StateMapperBase()
{
@Override
protected ModelResourceLocation getModelResourceLocation(IBlockState state)
{
return fluidLocation;
}
});
}
}
public static final class FiniteFluid extends Fluid
{
public static final String name = "finitefluid";
public static final FiniteFluid instance = new FiniteFluid();
private FiniteFluid()
{
super(name, new ResourceLocation("blocks/water_still"), new ResourceLocation("blocks/water_flow"), new ResourceLocation("blocks/water_overlay"));
}
@Override
public int getColor()
{
return 0xFFFFFF00;
}
@Override
public String getLocalizedName(FluidStack stack)
{
return "Finite Fluid";
}
}
public static final class FiniteFluidBlock extends BlockFluidFinite
{
public static final FiniteFluidBlock instance = new FiniteFluidBlock();
public static final String name = "finite_fluid_block";
private FiniteFluidBlock()
{
super(FiniteFluid.instance, Material.WATER);
setCreativeTab(CreativeTabs.BUILDING_BLOCKS);
setUnlocalizedName(MODID + ":" + name);
setRegistryName(MODID, name);
}
}
public static final class FluidItemBlock extends ItemBlock
{
FluidItemBlock(BlockFluidBase block)
{
super(block);
}
@Override
public BlockFluidBase getBlock()
{
return (BlockFluidBase) super.getBlock();
}
@Override
public int getMetadata(int damage)
{
return getBlock().getMaxRenderHeightMeta();
}
}
public static final class EmptyFluidContainer extends ItemBucket
{
public static final EmptyFluidContainer instance = new EmptyFluidContainer();
public static final String name = "empty_fluid_container";
private EmptyFluidContainer()
{
super(Blocks.AIR);
setRegistryName(MODID, name);
setUnlocalizedName(MODID + ":" + name);
setMaxStackSize(16);
}
@Override
public ICapabilityProvider initCapabilities(ItemStack stack, @Nullable NBTTagCompound nbt)
{
return new EmptyContainerHandler(stack);
}
private static final class EmptyContainerHandler extends FluidBucketWrapper
{
public EmptyContainerHandler(@Nonnull ItemStack container)
{
super(container);
}
@Override
public int fill(FluidStack resource, boolean doFill)
{
if (container.getCount() != 1 || resource == null || resource.amount > FluidAttributes.BUCKET_VOLUME || container
.getItem() instanceof ItemBucketMilk || getFluid() != null || !canFillFluidType(resource))
{
return 0;
}
if (doFill)
{
container = new ItemStack(FluidContainer.instance);
NBTTagCompound tag = new NBTTagCompound();
NBTTagCompound fluidTag = new NBTTagCompound();
resource.writeToNBT(fluidTag);
tag.setTag(FLUID_NBT_KEY, fluidTag);
container.setTagCompound(tag);
}
return resource.amount;
}
}
}
public static final class FluidContainer extends UniversalBucket
{
public static final FluidContainer instance = new FluidContainer();
public static final String name = "fluid_container";
private FluidContainer()
{
super(1000, new ItemStack(EmptyFluidContainer.instance), false);
setCreativeTab(CreativeTabs.MISC);
setRegistryName(MODID, name);
setUnlocalizedName(MODID + ":" + name);
}
@Nonnull
@Override
public String getItemStackDisplayName(@Nonnull ItemStack stack)
{
FluidStack fluid = getFluid(stack);
if (fluid == null || fluid.getFluid() == null)
{
return "Empty Variable Container";
}
return "Variable Container (" + getFluid(stack).getLocalizedName() + ")";
}
@Override
@Nullable
public FluidStack getFluid(ItemStack container)
{
container = container.copy();
if (container.getTagCompound() != null)
{
container.setTagCompound(container.getTagCompound().getCompoundTag(FLUID_NBT_KEY));
}
return super.getFluid(container);
}
@Override
@OnlyIn(Dist.CLIENT)
public void addInformation(ItemStack stack, @Nullable World playerIn, List<String> tooltip, ITooltipFlag advanced)
{
FluidStack fluid = getFluid(stack);
if (fluid != null)
{
tooltip.add(fluid.amount + "/1000");
}
}
@Override
public void getSubItems(@Nullable CreativeTabs tab, @Nonnull NonNullList<ItemStack> subItems)
{
if (!this.isInCreativeTab(tab))
return;
Fluid[] fluids = new Fluid[]{FluidRegistry.WATER, FluidRegistry.LAVA, FiniteFluid.instance, ModelFluidTest.FLUID};
// add 16 variable fillings
for (Fluid fluid : fluids)
{
for (int amount = 125; amount <= 1000; amount += 125)
{
for (int offset = 63; offset >= 0; offset -= 63)
{
FluidStack fs = new FluidStack(fluid, amount - offset);
ItemStack stack = new ItemStack(this);
NBTTagCompound tag = stack.getTagCompound();
if (tag == null)
{
tag = new NBTTagCompound();
}
NBTTagCompound fluidTag = new NBTTagCompound();
fs.writeToNBT(fluidTag);
tag.setTag(FLUID_NBT_KEY, fluidTag);
stack.setTagCompound(tag);
subItems.add(stack);
}
}
}
}
@Override
public ICapabilityProvider initCapabilities(ItemStack stack, NBTTagCompound nbt)
{
return new FluidHandlerItemStack.SwapEmpty(stack, new ItemStack(EmptyFluidContainer.instance), 1000);
}
}
}
*/

View File

@ -1,165 +0,0 @@
/*
* Minecraft Forge
* Copyright (c) 2016-2019.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation version 2.1
* of the License.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
/*
package net.minecraftforge.debug.fluid;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.NonNullList;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidRegistry;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.FluidUtil;
import net.minecraftforge.fluids.capability.IFluidHandlerItem;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.event.FMLLoadCompleteEvent;
import net.minecraftforge.fml.event.FMLPreInitializationEvent;
import net.minecraftforge.fml.common.registry.ForgeRegistries;
import org.apache.logging.log4j.Logger;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.util.List;
//@Mod(modid = "fluidhandlertest", name = "FluidHandlerTest", version = "0.0.0", clientSideOnly = true)
public class ItemFluidHandlerTest
{
public static final boolean ENABLE = false;
private static Logger logger;
@Mod.EventHandler
public void preInit(FMLPreInitializationEvent event)
{
if (ENABLE)
{
logger = event.getModLog();
}
}
@Mod.EventHandler
public void loadComplete(FMLLoadCompleteEvent event)
{
if (!ENABLE)
{
return;
}
for (ItemStack stack : getAllItems())
{
testFluidContainer(stack);
}
}
private static void testFluidContainer(ItemStack stack)
{
ItemStack originalStack = stack.copy();
ItemStack preDrainStack = stack.copy();
IFluidHandlerItem fluidHandler = FluidUtil.getFluidHandler(preDrainStack);
if (fluidHandler != null)
{
FluidStack drain = fluidHandler.drain(Integer.MAX_VALUE, true);
ItemStack drainedStack = fluidHandler.getContainer();
logger.info("Draining {} gives {} and {}", stackString(stack), fluidString(drain), stackString(drainedStack));
if (drain == null && !ItemStack.areItemStacksEqual(originalStack, preDrainStack))
{
throw new RuntimeException("ItemStack was altered by its fluid handler when drain did nothing.");
}
for (Fluid fluid : FluidRegistry.getRegisteredFluids().values())
{
ItemStack preFillStack = stack.copy();
fluidHandler = FluidUtil.getFluidHandler(preFillStack);
if (fluidHandler != null)
{
int filled = fluidHandler.fill(new FluidStack(fluid, Integer.MAX_VALUE), true);
ItemStack filledStack = fluidHandler.getContainer();
if (filled > 0)
{
logger.info("Filling {} with {} gives {}", stackString(stack), fluidString(new FluidStack(fluid, filled)), stackString(filledStack));
}
else
{
if (!ItemStack.areItemStacksEqual(originalStack, preFillStack))
{
throw new RuntimeException("ItemStack was altered by its fluid handler when fill did nothing.");
}
if (!ItemStack.areItemStacksEqual(preFillStack, filledStack))
{
throw new RuntimeException("ItemStack was altered by its fluid handler when fill did nothing.");
}
}
}
}
}
}
private static String fluidString(@Nullable FluidStack stack)
{
if (stack == null)
{
return "no fluid";
}
else
{
return stack.amount + "mB " + stack.getLocalizedName();
}
}
private static String stackString(@Nonnull ItemStack stack)
{
if (stack.isEmpty())
{
return "no item";
}
else
{
String resourceDomain;
if (stack.getItem().getRegistryName() == null)
{
resourceDomain = "unknown";
}
else
{
resourceDomain = stack.getItem().getRegistryName().getResourceDomain();
}
return stack.getCount() + " " + stack.getDisplayName() + " (" + resourceDomain + ")";
}
}
private static List<ItemStack> getAllItems()
{
NonNullList<ItemStack> list = NonNullList.create();
for (Item item : ForgeRegistries.ITEMS.getValuesCollection())
{
for (CreativeTabs tab : item.getCreativeTabs())
{
item.getSubItems(tab, list);
}
}
return list;
}
}
*/

View File

@ -1,92 +0,0 @@
/*
* Minecraft Forge
* Copyright (c) 2016-2019.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation version 2.1
* of the License.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
/*
package net.minecraftforge.debug.gameplay;
import net.minecraft.client.renderer.model.ModelResourceLocation;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.client.event.ModelRegistryEvent;
import net.minecraftforge.client.model.ModelLoader;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.RegistryEvent;
import net.minecraftforge.event.entity.player.SleepingTimeCheckEvent;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.event.FMLPreInitializationEvent;
import net.minecraftforge.fml.common.eventhandler.Event;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.common.registry.GameRegistry;
//@Mod(modid = AnytimeSleepingTest.MODID, name = "Anytime Sleeping Test", version = "0.0", acceptableRemoteVersions = "*")
public class AnytimeSleepingTest
{
public static final String MODID = "anytimesleepingtest";
@GameRegistry.ObjectHolder(ItemSleepCharm.NAME)
public static final Item SLEEP_CHARM = null;
@Mod.EventHandler
public void preInit(FMLPreInitializationEvent evt)
{
MinecraftForge.EVENT_BUS.register(this);
}
@SubscribeEvent
public void onCheckSleepTime(SleepingTimeCheckEvent evt)
{
EntityPlayer player = evt.getEntityPlayer();
if (player.getHeldItemMainhand().getItem() instanceof ItemSleepCharm)
{
evt.setResult(Event.Result.ALLOW);
}
}
//@Mod.EventBusSubscriber(modid = MODID)
public static class Registration
{
@SubscribeEvent
public static void registerItems(RegistryEvent.Register<Item> evt)
{
evt.getRegistry().register(new ItemSleepCharm());
}
@SubscribeEvent
public static void registerModels(ModelRegistryEvent evt)
{
ModelLoader.setCustomModelResourceLocation(SLEEP_CHARM, 0, new ModelResourceLocation("minecraft:totem", "inventory"));
}
}
public static class ItemSleepCharm extends Item
{
static final String NAME = "sleep_charm";
private ItemSleepCharm()
{
this.setCreativeTab(CreativeTabs.MISC);
this.setUnlocalizedName(MODID + ":" + NAME);
this.setRegistryName(new ResourceLocation(MODID, NAME));
}
}
}
*/

View File

@ -1,80 +0,0 @@
/*
* Minecraft Forge
* Copyright (c) 2016-2019.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation version 2.1
* of the License.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
/*
package net.minecraftforge.debug.gameplay;
import net.minecraft.init.Items;
import net.minecraft.item.ItemStack;
import net.minecraftforge.common.brewing.BrewingRecipeRegistry;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.Mod.EventHandler;
import net.minecraftforge.fml.event.FMLInitializationEvent;
import net.minecraftforge.fml.event.FMLPreInitializationEvent;
import org.apache.logging.log4j.Logger;
//@Mod(modid = "brewingreciperegistrytest", name = "BrewingRecipeRegistryTest", version = "0.0.0", acceptableRemoteVersions = "*")
public class BrewingRecipeRegistryTest
{
public static final boolean ENABLE = false;
private static Logger logger;
@EventHandler
public void preInit(FMLPreInitializationEvent event)
{
logger = event.getModLog();
}
@EventHandler
public void init(FMLInitializationEvent event)
{
if (!ENABLE)
{
return;
}
// The following adds a recipe that brews a piece of rotten flesh "into" a diamond sword resulting in a diamond hoe
BrewingRecipeRegistry.addRecipe(new ItemStack(Items.DIAMOND_SWORD), new ItemStack(Items.ROTTEN_FLESH), new ItemStack(Items.DIAMOND_HOE));
ItemStack output0 = BrewingRecipeRegistry.getOutput(new ItemStack(Items.DIAMOND_SWORD), new ItemStack(Items.ROTTEN_FLESH));
if (output0.getItem() == Items.DIAMOND_HOE)
{
logger.info("Recipe successfully registered and working. Diamond Hoe obtained.");
}
// Testing if OreDictionary support is working. Register a recipe that brews a gemDiamond into a gold sword resulting in a diamond sword
BrewingRecipeRegistry.addRecipe(new ItemStack(Items.GOLDEN_SWORD), "gemDiamond", new ItemStack(Items.DIAMOND_SWORD));
ItemStack output1 = BrewingRecipeRegistry.getOutput(new ItemStack(Items.GOLDEN_SWORD), new ItemStack(Items.DIAMOND));
if (output1.getItem() == Items.DIAMOND_SWORD)
{
logger.info("Recipe successfully registered and working. Diamond Sword obtained.");
}
// In vanilla, brewing netherwart into a water bottle results in an awkward potion (with metadata 16). The following tests if that still happens
ItemStack output2 = BrewingRecipeRegistry.getOutput(new ItemStack(Items.POTIONITEM, 1, 0), new ItemStack(Items.NETHER_WART));
if (output2 != null && output2.getItem() == Items.POTIONITEM && output2.getItemDamage() == 16)
{
logger.info("Vanilla behaviour still in place. Brewed Water Bottle with Nether Wart and got Awkward Potion");
}
}
}
*/

View File

@ -1,66 +0,0 @@
/*
* Minecraft Forge
* Copyright (c) 2016-2019.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation version 2.1
* of the License.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
/*
package net.minecraftforge.debug.gameplay;
import java.io.IOException;
import java.util.Map;
import java.util.stream.Stream;
import net.minecraft.init.Items;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.Ingredient;
import net.minecraft.item.crafting.Ingredient.IItemList;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.common.crafting.CraftingHelper;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.event.server.FMLServerStartedEvent;
//@Mod(ConstantLoadingTest.MODID)
//@Mod.EventBusSubscriber
public class ConstantLoadingTest
{
public static final String MODID = "constantloadingtest";
private static final boolean ENABLED = true;
@SubscribeEvent
public void init(FMLServerStartedEvent event) throws IOException
{
if (!ENABLED)
{
return;
}
Map<ResourceLocation, IItemList> constants = CraftingHelper.loadConstants(event.getServer().getResourceManager(), new ResourceLocation(MODID, "test/_constants.json"));
Ingredient flint = Ingredient.fromItemListStream(Stream.of(constants.get(new ResourceLocation("FLINT"))));
if (flint == null)
{
throw new IllegalStateException("Constant ingredient not loaded properly");
}
if (!flint.test(new ItemStack(Items.FLINT)))
{
throw new IllegalStateException("Constant ingredient failed to match test input");
}
}
}
*/

View File

@ -1,83 +0,0 @@
/*
* Minecraft Forge
* Copyright (c) 2016-2019.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation version 2.1
* of the License.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
/*
package net.minecraftforge.debug.gameplay;
import com.google.gson.JsonObject;
import net.minecraft.item.crafting.IRecipe;
import net.minecraft.item.crafting.Ingredient;
import net.minecraftforge.common.crafting.IConditionFactory;
import net.minecraftforge.common.crafting.IIngredientFactory;
import net.minecraftforge.common.crafting.IRecipeFactory;
import net.minecraftforge.common.crafting.JsonContext;
import net.minecraftforge.event.RegistryEvent;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import java.util.function.BooleanSupplier;
//@Mod(modid = CraftingSystemTest.MOD_ID, name = "CraftingTestMod", version = "1.0", acceptableRemoteVersions = "*")
//@Mod.EventBusSubscriber
public class CraftingSystemTest
{
static final String MOD_ID = "crafting_system_test";
static final boolean ENABLED = false;
static final Logger logger = LogManager.getLogger(MOD_ID);
@net.minecraftforge.eventbus.api.SubscribeEvent
public static void registerRecipes(RegistryEvent.Register<IRecipe> event)
{
logger.info("Registering Test Recipes:");
}
public static class IngredientFactory implements IIngredientFactory
{
@Override
public Ingredient parse(JsonContext context, JsonObject json)
{
return null;
}
}
public static class RecipeFactory implements IRecipeFactory
{
@Override
public IRecipe parse(JsonContext context, JsonObject json)
{
return null;
}
}
public static class ConditionFactory implements IConditionFactory
{
@Override
public BooleanSupplier parse(JsonContext context, JsonObject json)
{
return () -> true;
}
}
}
*/

View File

@ -1,54 +0,0 @@
/*
* Minecraft Forge
* Copyright (c) 2016-2019.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation version 2.1
* of the License.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
/*
package net.minecraftforge.debug.gameplay;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.DifficultyChangeEvent;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.Mod.EventHandler;
import net.minecraftforge.fml.event.FMLPreInitializationEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import org.apache.logging.log4j.Logger;
//@Mod(modid = "difficultychangeeventtest", name = "DifficultyChangeEventTest", version = "0.0.0", acceptableRemoteVersions = "*")
public class DifficultyChangeEventTest
{
private static final boolean ENABLE = false;
private static Logger logger;
@EventHandler
public void preInit(FMLPreInitializationEvent event)
{
if (ENABLE)
{
logger = event.getModLog();
MinecraftForge.EVENT_BUS.register(this);
}
}
@net.minecraftforge.eventbus.api.SubscribeEvent
public void onDifficultyChange(DifficultyChangeEvent event)
{
logger.info("Difficulty changed from {} to {}", event.getOldDifficulty(), event.getDifficulty());
}
}*/

View File

@ -1,188 +0,0 @@
/*
* Minecraft Forge
* Copyright (c) 2016-2019.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation version 2.1
* of the License.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
/*
package net.minecraftforge.debug.gameplay;
import java.io.IOException;
import java.io.InputStream;
import javax.imageio.ImageIO;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.BannerTextures;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.EnumDyeColor;
import net.minecraft.item.ItemBanner;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.tileentity.BannerPattern;
import net.minecraft.util.NonNullList;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.client.MinecraftForgeClient;
import net.minecraftforge.common.util.EnumHelper;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.SidedProxy;
import net.minecraftforge.fml.event.FMLPreInitializationEvent;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
// TODO 1.13: implement without java.awt
//@Mod(modid = DynamicBannerTest.MODID, name = "ForgeDebugDynamicBanner", version = DynamicBannerTest.VERSION, acceptableRemoteVersions = "*")
public class DynamicBannerTest
{
private static final boolean ENABLE = false;
public static final String MODID = "forgedebugdynamicbanner";
public static final String VERSION = "1.0";
public static CreativeTabs bannerTab;
@SidedProxy
public static CommonProxy proxy = null;
@Mod.EventHandler
public void preInit(FMLPreInitializationEvent event)
{
if (ENABLE)
{
BannerPattern pattern = addBasicPattern("Y");
proxy.registerSupplier(new ResourceLocation("textures/entity/banner/" + pattern.getFileName() + ".png"));
proxy.registerSupplier(new ResourceLocation("textures/entity/shield/" + pattern.getFileName() + ".png"));
bannerTab = new CreativeTabBanners("dynbanner.banners");
}
}
public static abstract class CommonProxy
{
public void registerSupplier(ResourceLocation location)
{
}
}
public static final class ServerProxy extends CommonProxy
{
}
public static final class ClientProxy extends CommonProxy
{
@Override
@SideOnly(Side.CLIENT)
public void registerSupplier(ResourceLocation location)
{
MinecraftForgeClient.registerImageLayerSupplier(location, () -> {
return createBufferedImage();
});
}
}
public static BannerPattern addBasicPattern(String name)
{
final Class<?>[] paramTypes = { String.class, String.class };
final Object[] paramValues = { MODID + "_" + name, MODID + "." + name };
return EnumHelper.addEnum(BannerPattern.class, name.toUpperCase(), paramTypes, paramValues);
}
@SideOnly(Side.CLIENT)
private static BufferedImage createBufferedImage()
{
BufferedImage baseImage = buildBackground();
int width = 11;
int height = 30;
int startX = 5;
int startY = 5;
for (int xx = startX; xx <= startX + width; xx++)
{
for (int yy = startY; yy <= startY + height; yy++)
{
baseImage.setRGB(xx, yy, 0xFF000000); // Black
}
}
return baseImage;
}
@SideOnly(Side.CLIENT)
private static BufferedImage buildBackground()
{
ResourceLocation originalBackground = BannerTextures.BANNER_BASE_TEXTURE;
try (InputStream is = Minecraft.getMinecraft().getResourceManager().getResource(originalBackground).getInputStream())
{
return ImageIO.read(is);
}
catch (IOException exc)
{
throw new RuntimeException("Couldn't find or open the page background image.", exc);
}
}
public static NBTTagList makePatternNBTList(BannerPattern pattern, EnumDyeColor color)
{
final NBTTagList patterns = new NBTTagList();
final NBTTagCompound tag = new NBTTagCompound();
tag.setString("Pattern", pattern.getHashname());
tag.setInteger("Color", color.getDyeDamage());
patterns.appendTag(tag);
return patterns;
}
public static class CreativeTabBanners extends CreativeTabs
{
private static ItemStack DISPLAY = null;
public CreativeTabBanners(String id)
{
super(id);
this.setBackgroundImageName("item_search.png");
}
@Override
public ItemStack getTabIconItem()
{
return this.getIconItemStack();
}
@Override
public ItemStack getIconItemStack()
{
if (DISPLAY == null)
DISPLAY = ItemBanner.makeBanner(EnumDyeColor.WHITE, makePatternNBTList(BannerPattern.CREEPER, EnumDyeColor.GREEN));
return DISPLAY;
}
@Override
public boolean hasSearchBar()
{
return true;
}
@Override
public void displayAllRelevantItems(NonNullList<ItemStack> itemList)
{
super.displayAllRelevantItems(itemList);
for (final BannerPattern pattern : BannerPattern.values())
itemList.add(ItemBanner.makeBanner(EnumDyeColor.WHITE, makePatternNBTList(pattern, EnumDyeColor.BLACK)));
}
}
}
*/

View File

@ -1,57 +0,0 @@
/*
* Minecraft Forge
* Copyright (c) 2016-2019.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation version 2.1
* of the License.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
/*
package net.minecraftforge.debug.gameplay;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.enchanting.EnchantmentLevelSetEvent;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.event.FMLPreInitializationEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import org.apache.logging.log4j.Logger;
//@Mod(modid = "enchantmentlevelsettest", name = "EnchantmentLevelSetTest", version = "1.0", acceptableRemoteVersions = "*")
public class EnchantmentLevelSetEventTest
{
public static final boolean ENABLE = false;
private static Logger logger;
@Mod.EventHandler
public static void preInit(FMLPreInitializationEvent event)
{
if (ENABLE)
{
logger = event.getModLog();
logger.info("Wiring up enchantment level set test");
MinecraftForge.EVENT_BUS.register(EnchantmentLevelSetEventTest.class);
}
}
@SubscribeEvent
public static void onEnchantmentLevelSet(EnchantmentLevelSetEvent event)
{
// invert enchantment level, just for fun
logger.info("Enchantment row: {}, level: {}", event.getEnchantRow(), event.getLevel());
event.setLevel(30 - event.getLevel());
}
}
*/

View File

@ -1,134 +0,0 @@
/*
* Minecraft Forge
* Copyright (c) 2016-2019.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation version 2.1
* of the License.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
/*
package net.minecraftforge.debug.gameplay;
import net.minecraft.client.renderer.model.ModelBakery;
import net.minecraft.client.renderer.model.ModelResourceLocation;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.item.ItemSpade;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.client.event.ModelRegistryEvent;
import net.minecraftforge.client.model.ModelLoader;
import net.minecraftforge.event.RegistryEvent;
import net.minecraftforge.event.furnace.FurnaceFuelBurnTimeEvent;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.registry.GameRegistry;
//@Mod(modid = FurnaceFuelBurnTimeEventTest.MOD_ID, name = "Test for FurnaceFuelBurnTimeEvent", version = "1.0", acceptableRemoteVersions = "*")
//@Mod.EventBusSubscriber
public class FurnaceFuelBurnTimeEventTest
{
public static final String MOD_ID = "furnacefuelburntimeeventtest";
private static final ResourceLocation unburnableWoodShovelName = new ResourceLocation(MOD_ID, "unburnable_wood_shovel");
private static final ResourceLocation flammableGoldShovelName = new ResourceLocation(MOD_ID, "flammable_gold_shovel");
@GameRegistry.ObjectHolder("unburnable_wood_shovel")
public static final Item UNBURNABLE_WOOD_SHOVEL = null;
@GameRegistry.ObjectHolder("flammable_gold_shovel")
public static final Item FLAMMABLE_GOLD_SHOVEL = null;
@SubscribeEvent
public static void onFurnaceFuelBurnTimeEvent(FurnaceFuelBurnTimeEvent event)
{
ItemStack itemStack = event.getItemStack();
Item item = itemStack.getItem();
if (item == Items.SLIME_BALL)
{
event.setBurnTime(100); // make slime balls burn as fuel in the furnace
}
else if (item == Items.WOODEN_AXE)
{
event.setBurnTime(0); // do not allow the wooden axe to be used as fuel
}
}
@SubscribeEvent
public static void registerItems(RegistryEvent.Register<Item> event)
{
event.getRegistry().register(new UnburnableWoodShovel().setRegistryName(unburnableWoodShovelName));
event.getRegistry().register(new FlammableGoldShovel().setRegistryName(flammableGoldShovelName));
}
@SubscribeEvent
public static void registerModels(ModelRegistryEvent event)
{
{
final ModelResourceLocation location = new ModelResourceLocation(unburnableWoodShovelName, "inventory");
ModelBakery.registerItemVariants(UNBURNABLE_WOOD_SHOVEL, location);
ModelLoader.setCustomMeshDefinition(UNBURNABLE_WOOD_SHOVEL, is -> location);
}
{
final ModelResourceLocation location = new ModelResourceLocation(flammableGoldShovelName, "inventory");
ModelBakery.registerItemVariants(FLAMMABLE_GOLD_SHOVEL, location);
ModelLoader.setCustomMeshDefinition(FLAMMABLE_GOLD_SHOVEL, is -> location);
}
}
public static class UnburnableWoodShovel extends ItemSpade
{
public UnburnableWoodShovel()
{
super(ToolMaterial.WOOD);
setCreativeTab(CreativeTabs.TOOLS);
setMaxStackSize(1);
}
@Override
public int getItemBurnTime(ItemStack itemStack)
{
return 0;
}
@Override
public String getItemStackDisplayName(ItemStack stack)
{
return "Unburnable Wooden Shovel";
}
}
public static class FlammableGoldShovel extends ItemSpade
{
public FlammableGoldShovel()
{
super(ToolMaterial.GOLD);
setCreativeTab(CreativeTabs.TOOLS);
setMaxStackSize(1);
}
@Override
public int getItemBurnTime(ItemStack itemStack)
{
return 1000;
}
@Override
public String getItemStackDisplayName(ItemStack stack)
{
return "Flammable Golden Shovel";
}
}
}
*/

View File

@ -1,66 +0,0 @@
/*
* Minecraft Forge
* Copyright (c) 2016-2019.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation version 2.1
* of the License.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
/*
package net.minecraftforge.debug.gameplay;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumActionResult;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.entity.player.PlayerInteractEvent;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.event.FMLPreInitializationEvent;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.common.registry.GameRegistry;
import net.minecraftforge.items.ItemHandlerHelper;
*/
/**
* A mod to test that ItemHandlerHelper.giveItemToPlayer works.
* More specifically, that all players, including the one receiving the item, can hear the pickup sound when it happens.
* This mod makes it so when you right click the air with a piece of dirt in your hand, you get another piece of dirt.
* It's not a dupe glitch...it's a dupe "feature"...
*//*
//@Mod(modid = "giveitemtoplayertest", name = "ItemHandlerHelper.giveItemToPlayer Test", version = "1.0")
public class GiveItemToPlayerTest {
private static final boolean ENABLED = false;
@GameRegistry.ItemStackHolder("minecraft:dirt")
public static final ItemStack dirt = null;
@Mod.EventHandler
public void preInit(FMLPreInitializationEvent event) {
if (ENABLED) {
MinecraftForge.EVENT_BUS.register(this);
}
}
@SubscribeEvent
public void rightClick(PlayerInteractEvent.RightClickItem event) {
if (!event.getWorld().isRemote && event.getItemStack().isItemEqual(dirt)) {
ItemHandlerHelper.giveItemToPlayer(event.getEntityPlayer(), dirt);
}
event.setCanceled(true);
event.setCancellationResult(EnumActionResult.SUCCESS);
}
}
*/

View File

@ -1,70 +0,0 @@
/*
* Minecraft Forge
* Copyright (c) 2016-2019.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation version 2.1
* of the License.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
/*
package net.minecraftforge.debug.gameplay;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.text.TextComponentString;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.client.event.InputUpdateEvent;
import net.minecraftforge.fml.common.Mod;
//@Mod(modid = InputUpdateEventTest.MODID, name = "InputUpdateTest", version = "1.0", acceptableRemoteVersions = "*")
public class InputUpdateEventTest
{
static final String MODID = "input_update_test";
//@Mod.EventBusSubscriber(value = Side.CLIENT, modid = MODID)
public static class Registration
{
@net.minecraftforge.eventbus.api.SubscribeEvent
public static void onInputUpdate(InputUpdateEvent evt)
{
EntityPlayer player = evt.getEntityPlayer();
final int x = MathHelper.floor(player.posX);
final int y = MathHelper.floor(player.getEntityBoundingBox().minY) - 1;
final int z = MathHelper.floor(player.posZ);
final BlockPos pos = new BlockPos(x, y, z);
IBlockState blockUnder = player.world.getBlockState(pos);
if (blockUnder.getBlock() == Blocks.BLACK_GLAZED_TERRACOTTA)
{
if (evt.getMovementInput().jump)
{
player.sendMessage(new TextComponentString("NO JUMPING!"));
evt.getMovementInput().jump = false;
}
if (evt.getMovementInput().sneak)
{
player.sendMessage(new TextComponentString("NO SNEAKING!"));
evt.getMovementInput().sneak = false;
}
}
}
}
}
*/

View File

@ -1,229 +0,0 @@
/*
* Minecraft Forge
* Copyright (c) 2016-2019.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation version 2.1
* of the License.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
/*
package net.minecraftforge.debug.gameplay;
import net.minecraft.client.renderer.model.ModelResourceLocation;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayer.SleepResult;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTBase;
import net.minecraft.nbt.NBTPrimitive;
import net.minecraft.nbt.NBTTagByte;
import net.minecraft.util.ActionResult;
import net.minecraft.util.EnumActionResult;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumHand;
import net.minecraft.util.ResourceLocation;
import net.minecraft.world.World;
import net.minecraftforge.client.event.ModelRegistryEvent;
import net.minecraftforge.client.model.ModelLoader;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.common.capabilities.Capability;
import net.minecraftforge.common.capabilities.Capability.IStorage;
import net.minecraftforge.common.capabilities.CapabilityInject;
import net.minecraftforge.common.capabilities.CapabilityManager;
import net.minecraftforge.common.capabilities.ICapabilitySerializable;
import net.minecraftforge.event.AttachCapabilitiesEvent;
import net.minecraftforge.event.RegistryEvent;
import net.minecraftforge.event.entity.player.PlayerWakeUpEvent;
import net.minecraftforge.event.entity.player.SleepingLocationCheckEvent;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.event.FMLPreInitializationEvent;
import net.minecraftforge.eventbus.api.Event.Result;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.registry.GameRegistry.ObjectHolder;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
//@Mod(modid = NoBedSleepingTest.MODID, name = "ForgeDebugNoBedSleeping", version = NoBedSleepingTest.VERSION, acceptableRemoteVersions = "*")
public class NoBedSleepingTest
{
public static final String MODID = "forgedebugnobedsleeping";
public static final String VERSION = "1.0";
@CapabilityInject(IExtraSleeping.class)
private static final Capability<IExtraSleeping> SLEEP_CAP = null;
@ObjectHolder(ItemSleepingPill.name)
public static final Item SLEEPING_PILL = null;
//@Mod.EventBusSubscriber(modid = MODID)
public static class Registration
{
@SubscribeEvent
public static void registerItems(RegistryEvent.Register<Item> event)
{
event.getRegistry().register(new ItemSleepingPill());
}
@SubscribeEvent
public static void registerModels(ModelRegistryEvent event)
{
ModelLoader.setCustomModelResourceLocation(SLEEPING_PILL, 0, new ModelResourceLocation(SLEEPING_PILL.getRegistryName(), "inventory"));
}
}
@Mod.EventHandler
public void preInit(FMLPreInitializationEvent event)
{
CapabilityManager.INSTANCE.register(IExtraSleeping.class, new Storage(), DefaultImpl::new);
MinecraftForge.EVENT_BUS.register(new EventHandler());
}
public static class EventHandler
{
@SubscribeEvent
public void onEntityConstruct(AttachCapabilitiesEvent<Entity> evt)
{
if (!(evt.getObject() instanceof EntityPlayer))
{
return;
}
evt.addCapability(new ResourceLocation(MODID, "IExtraSleeping"), new ICapabilitySerializable<NBTPrimitive>()
{
IExtraSleeping inst = SLEEP_CAP.getDefaultInstance();
@Override
public boolean hasCapability(@Nonnull Capability<?> capability, @Nullable EnumFacing facing)
{
return capability == SLEEP_CAP;
}
@Override
@Nullable
public <T> T getCapability(@Nonnull Capability<T> capability, @Nullable EnumFacing facing)
{
return capability == SLEEP_CAP ? SLEEP_CAP.<T>cast(inst) : null;
}
@Override
public NBTPrimitive serializeNBT()
{
return (NBTPrimitive) SLEEP_CAP.getStorage().writeNBT(SLEEP_CAP, inst, null);
}
@Override
public void deserializeNBT(NBTPrimitive nbt)
{
SLEEP_CAP.getStorage().readNBT(SLEEP_CAP, inst, null, nbt);
}
});
}
@SubscribeEvent
public void onBedCheck(SleepingLocationCheckEvent evt)
{
final IExtraSleeping sleep = evt.getEntityPlayer().getCapability(SLEEP_CAP, null);
if (sleep != null && sleep.isSleeping())
{
evt.setResult(Result.ALLOW);
}
}
@SubscribeEvent
public void onWakeUp(PlayerWakeUpEvent evt)
{
final IExtraSleeping sleep = evt.getEntityPlayer().getCapability(SLEEP_CAP, null);
if (sleep != null)
{
sleep.setSleeping(false);
}
}
}
public interface IExtraSleeping
{
boolean isSleeping();
void setSleeping(boolean value);
}
public static class Storage implements IStorage<IExtraSleeping>
{
@Override
public NBTBase writeNBT(Capability<IExtraSleeping> capability, IExtraSleeping instance, EnumFacing side)
{
return new NBTTagByte((byte) (instance.isSleeping() ? 1 : 0));
}
@Override
public void readNBT(Capability<IExtraSleeping> capability, IExtraSleeping instance, EnumFacing side, NBTBase nbt)
{
instance.setSleeping(((NBTPrimitive) nbt).getByte() == 1);
}
}
public static class DefaultImpl implements IExtraSleeping
{
private boolean isSleeping = false;
@Override
public boolean isSleeping()
{
return isSleeping;
}
@Override
public void setSleeping(boolean value)
{
this.isSleeping = value;
}
}
public static class ItemSleepingPill extends Item
{
public static final String name = "sleeping_pill";
private ItemSleepingPill()
{
setCreativeTab(CreativeTabs.MISC);
setUnlocalizedName(MODID + ":" + name);
setRegistryName(new ResourceLocation(MODID, name));
}
@Override
@Nonnull
public ActionResult<ItemStack> onItemRightClick(@Nonnull World world, @Nonnull EntityPlayer player, @Nonnull EnumHand hand)
{
ItemStack stack = player.getHeldItem(hand);
if (!world.isRemote)
{
final SleepResult result = player.trySleep(player.getPosition());
if (result == SleepResult.OK)
{
final IExtraSleeping sleep = player.getCapability(SLEEP_CAP, null);
if (sleep != null)
{
sleep.setSleeping(true);
}
return ActionResult.newResult(EnumActionResult.SUCCESS, stack);
}
}
return ActionResult.newResult(EnumActionResult.PASS, stack);
}
}
}
*/

View File

@ -1,131 +0,0 @@
/*
* Minecraft Forge
* Copyright (c) 2016-2019.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation version 2.1
* of the License.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
/*
package net.minecraftforge.debug.gameplay;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.Gui;
import net.minecraft.client.renderer.BufferBuilder;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.client.renderer.texture.TextureMap;
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
import net.minecraft.potion.Potion;
import net.minecraft.potion.PotionEffect;
import net.minecraftforge.event.RegistryEvent;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import org.lwjgl.opengl.GL11;
import java.util.Random;
//@Mod.EventBusSubscriber
//@Mod(modid = PotionRegistryTest.MODID, name = "ForgePotionRegistry", version = "1.0", acceptableRemoteVersions = "*")
public class PotionRegistryTest
{
public static final String MOD_ID = "forge_potion_registry";
@SubscribeEvent
public static void registerPotions(RegistryEvent.Register<Potion> event)
{
event.getRegistry().register(
new PotionForge(false, 0xff00ff)
.setRegistryName(MOD_ID, "forge")
.setPotionName("potion." + MOD_ID + ".forge")
);
}
private static class PotionForge extends Potion
{
PotionForge(boolean badEffect, int potionColor)
{
super(badEffect, potionColor);
}
@Override
@SideOnly(Side.CLIENT)
public void renderInventoryEffect(PotionEffect effect, Gui gui, int x, int y, float z)
{
Potion potion = effect.getPotion();
Minecraft.getMinecraft().getTextureManager().bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
TextureAtlasSprite sprite = Minecraft.getMinecraft().getTextureMapBlocks().getAtlasSprite("minecraft:blocks/fire_layer_0");
x += 6;
y += 7;
int width = 18;
int height = width;
float r = (float) (potion.getLiquidColor() >> 24 & 255) / 255.0F;
float g = (float) (potion.getLiquidColor() >> 16 & 255) / 255.0F;
float b = (float) (potion.getLiquidColor() >> 8 & 255) / 255.0F;
float a = (float) (potion.getLiquidColor() & 255) / 255.0F;
Tessellator tessellator = Tessellator.getInstance();
BufferBuilder buf = tessellator.getBuffer();
buf.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX);
GlStateManager.color(r, g, b, a);
buf.pos((double) x, (double) (y + height), z).tex(sprite.getMinU(), sprite.getMaxV()).endVertex();
buf.pos((double) (x + width), (double) (y + height), z).tex(sprite.getMaxU(), sprite.getMaxV()).endVertex();
buf.pos((double) (x + width), (double) y, z).tex(sprite.getMaxU(), sprite.getMinV()).endVertex();
buf.pos((double) x, (double) y, z).tex(sprite.getMinU(), sprite.getMinV()).endVertex();
tessellator.draw();
}
@Override
@SideOnly(Side.CLIENT)
public void renderHUDEffect(PotionEffect effect, Gui gui, int x, int y, float z, float alpha)
{
Potion potion = effect.getPotion();
Minecraft.getMinecraft().getTextureManager().bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
TextureAtlasSprite sprite = Minecraft.getMinecraft().getTextureMapBlocks().getAtlasSprite("minecraft:blocks/tnt_side");
x += 3;
y += 3;
int width = 18;
int height = width;
float r = (float) (potion.getLiquidColor() >> 24 & 255) / 255.0F;
float g = (float) (potion.getLiquidColor() >> 16 & 255) / 255.0F;
float b = (float) (potion.getLiquidColor() >> 8 & 255) / 255.0F;
Tessellator tessellator = Tessellator.getInstance();
BufferBuilder buf = tessellator.getBuffer();
buf.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX);
GlStateManager.color(r, g, b, alpha);
buf.pos((double) x, (double) (y + height), z).tex(sprite.getMinU(), sprite.getMaxV()).endVertex();
buf.pos((double) (x + width), (double) (y + height), z).tex(sprite.getMaxU(), sprite.getMaxV()).endVertex();
buf.pos((double) (x + width), (double) y, z).tex(sprite.getMaxU(), sprite.getMinV()).endVertex();
buf.pos((double) x, (double) y, z).tex(sprite.getMinU(), sprite.getMinV()).endVertex();
tessellator.draw();
}
}
}
*/

View File

@ -1,124 +0,0 @@
/*
* Minecraft Forge
* Copyright (c) 2016-2019.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation version 2.1
* of the License.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
/*
package net.minecraftforge.debug.gameplay;
import java.util.Random;
import net.minecraft.client.renderer.model.ModelResourceLocation;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.init.Blocks;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.IRecipe;
import net.minecraft.item.crafting.ShapedRecipes;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.client.model.ModelLoader;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.common.crafting.CraftingHelper;
import net.minecraftforge.event.RegistryEvent;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.event.FMLPreInitializationEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.oredict.ShapedOreRecipe;
//@Mod(modid = RecipeMatchingTest.MODID, name = "Recipe test mod", version = "1.0", acceptableRemoteVersions = "*")
public class RecipeMatchingTest
{
public static final String MODID = "recipetest";
private static final boolean ENABLED = true;
public static CommonProxy proxy = null;
@Mod.EventHandler
public void preinit(FMLPreInitializationEvent event)
{
if (ENABLED)
MinecraftForge.EVENT_BUS.register(this);
}
@SubscribeEvent
public void registerRecipes(RegistryEvent.Register<IRecipe> event)
{
ResourceLocation location1 = new ResourceLocation(MODID, "dirt");
ShapedOreRecipe recipe1 = new ShapedOreRecipe(location1, new ItemStack(Blocks.DIAMOND_BLOCK), "DDD", 'D', new ItemStack(Blocks.DIRT));
recipe1.setRegistryName(location1);
event.getRegistry().register(recipe1);
if (FMLLaunchHandler.side() == Side.SERVER)
{
ResourceLocation location2 = new ResourceLocation(MODID, "stone");
CraftingHelper.ShapedPrimer primer1 = CraftingHelper.parseShaped("SSS", 'S', new ItemStack(Blocks.IRON_BLOCK));
ShapedRecipes recipe2 = new ShapedRecipes(location2.getResourcePath(), primer1.width, primer1.height, primer1.input, new ItemStack(Blocks.GOLD_BLOCK));
recipe2.setRegistryName(location2);
event.getRegistry().register(recipe2);
}
}
@SubscribeEvent
public void registerItems(RegistryEvent.Register<Item> event)
{
proxy.registerItem(event);
}
public static abstract class CommonProxy
{
protected Item TOOL;
public void registerItem(RegistryEvent.Register<Item> event)
{
TOOL = new Item()
{
Random RAND = new Random();
@Override
public ItemStack getContainerItem(ItemStack in)
{
ItemStack ret = in.copy();
ret.attemptDamageItem(1, RAND, null);
return ret;
}
@Override
public boolean hasContainerItem()
{
return true;
}
}.setRegistryName(MODID, "tool").setMaxDamage(10).setCreativeTab(CreativeTabs.MISC).setUnlocalizedName("recipetest.tool").setMaxStackSize(1);
event.getRegistry().register(TOOL);
}
}
public static final class ServerProxy extends CommonProxy
{
}
public static final class ClientProxy extends CommonProxy
{
@Override
public void registerItem(RegistryEvent.Register<Item> event)
{
super.registerItem(event);
ModelLoader.setCustomModelResourceLocation(TOOL, 0, new ModelResourceLocation("minecraft:stick#inventory"));
}
}
}
*/

View File

@ -1,55 +0,0 @@
/*
* Minecraft Forge
* Copyright (c) 2016-2019.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation version 2.1
* of the License.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
/*
package net.minecraftforge.debug.gameplay.advancement;
import net.minecraft.advancements.CriteriaTriggers;
import net.minecraft.advancements.critereon.PositionTrigger;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.event.FMLPreInitializationEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.event.TickEvent;
//@Mod(name = "advancementcriteriontest", modid = "advancementcriteriontest", version = "1.0", acceptableRemoteVersions = "*")
//@Mod.EventBusSubscriber
public class AdvancementCriterionTest {
private static final PositionTrigger TRIGGER = new PositionTrigger(new ResourceLocation("advancementcriteriontest", "position"));
@Mod.EventHandler
public void preinit(FMLPreInitializationEvent evt)
{
CriteriaTriggers.register(TRIGGER);
}
@SubscribeEvent
public static void onTick(TickEvent.PlayerTickEvent evt)
{
if (evt.side == Side.SERVER && evt.phase == TickEvent.Phase.END)
{
TRIGGER.trigger((EntityPlayerMP) evt.player);
}
}
}
*/

View File

@ -1,59 +0,0 @@
/*
* Minecraft Forge
* Copyright (c) 2016-2019.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation version 2.1
* of the License.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
/*
package net.minecraftforge.debug.gameplay.advancement;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.entity.player.AdvancementEvent;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.event.FMLPreInitializationEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import org.apache.logging.log4j.Logger;
//@Mod(modid = AdvancementEventTest.MOD_ID, name = "AdvancementEvent test mod", version = "1.0.0", acceptableRemoteVersions = "*")
public class AdvancementEventTest
{
static final String MOD_ID = "advancement_event_test";
private static final boolean ENABLED = false;
private static Logger logger;
@Mod.EventHandler
public void preInit(FMLPreInitializationEvent event)
{
logger = event.getModLog();
if (ENABLED)
{
MinecraftForge.EVENT_BUS.register(AdvancementEventTest.class);
}
}
@SubscribeEvent
public static void onAdvancementEvent(AdvancementEvent event)
{
if (event.getAdvancement().getDisplay() != null && event.getAdvancement().getDisplay().shouldAnnounceToChat())
{
logger.info("{} got the {} advancement", event.getEntityPlayer().getDisplayNameString(), event.getAdvancement().getDisplayText().getUnformattedText());
}
}
}
*/

View File

@ -1,27 +0,0 @@
/*
* Minecraft Forge
* Copyright (c) 2016-2019.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation version 2.1
* of the License.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
package net.minecraftforge.debug.gameplay.advancement;
import net.minecraftforge.fml.common.Mod;
//@Mod(modid = "advancements_pagination", name = "Advancements Pagination test mod", version = "1.0", acceptableRemoteVersions = "*")
public class AdvancementsPaginationTest
{
}

View File

@ -1,227 +0,0 @@
/*
* Minecraft Forge
* Copyright (c) 2016-2019.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation version 2.1
* of the License.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
/*
package net.minecraftforge.debug.gameplay.advancement;
import com.google.gson.JsonDeserializationContext;
import com.google.gson.JsonObject;
import net.minecraft.advancements.CriteriaTriggers;
import net.minecraft.advancements.ICriterionTrigger;
import net.minecraft.advancements.PlayerAdvancements;
import net.minecraft.advancements.critereon.AbstractCriterionInstance;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.event.entity.EntityJoinWorldEvent;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import java.lang.invoke.MethodHandle;
import java.lang.invoke.MethodHandles;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
*/
/**
* Most of the real work is in the advancements directory of this mod.
* This mod tests ore-dict advancement triggers.
*//*
//@Mod.EventBusSubscriber
//@Mod(modid = OredictTriggerTest.MODID, name = "Oredict Item Predicate Test", version = "1.0", acceptableRemoteVersions = "*")
public class OredictTriggerTest
{
public static final String MODID = "oredict_predicate";
static final boolean ENABLED = false;
private static final MethodHandle ctRegister;
static
{
try
{
final Method tmp = CriteriaTriggers.class.getDeclaredMethod("register"*/
/* func_192118_a *//*
, ICriterionTrigger.class);
tmp.setAccessible(true);
ctRegister = MethodHandles.lookup().unreflect(tmp);
}
catch (Throwable e)
{
throw new RuntimeException(e);
}
}
public static final EnabledTrigger ENABLED_TRIGGER;
static
{
try
{
ENABLED_TRIGGER = (EnabledTrigger)(ICriterionTrigger)ctRegister.invokeExact((ICriterionTrigger)new EnabledTrigger());
}
catch (Throwable e)
{
throw new RuntimeException(e);
}
}
// trigger the enabled advancement on player entry
@SubscribeEvent
public static void triggerAdv(EntityJoinWorldEvent event)
{
if (event.getEntity() instanceof EntityPlayerMP)
{
final EntityPlayerMP player = (EntityPlayerMP)event.getEntity();
ENABLED_TRIGGER.trigger(player, player.inventory);
}
}
*/
/**
* Far more work than expectedoh well.
*//*
public static class EnabledTrigger implements ICriterionTrigger<EnabledTrigger.Instance>
{
public static final ResourceLocation ID = new ResourceLocation(MODID, "is_enabled");
private final Map<PlayerAdvancements, Listeners> listeners = new HashMap<>();
@Override
public ResourceLocation getId()
{
return ID;
}
@Override
public void addListener(PlayerAdvancements playerAdvancementsIn, Listener<Instance> listener)
{
Listeners listeners = this.listeners.computeIfAbsent(playerAdvancementsIn, Listeners::new);
listeners.add(listener);
}
@Override
public void removeListener(PlayerAdvancements playerAdvancementsIn, Listener<Instance> listener)
{
Listeners listeners = this.listeners.get(playerAdvancementsIn);
if (listeners != null)
{
listeners.remove(listener);
if (listeners.isEmpty())
{
this.listeners.remove(playerAdvancementsIn);
}
}
}
@Override
public void removeAllListeners(PlayerAdvancements playerAdvancementsIn)
{
this.listeners.remove(playerAdvancementsIn);
}
@Override
public Instance deserializeInstance(JsonObject json, JsonDeserializationContext context)
{
return new Instance();
}
public void trigger(EntityPlayerMP player, InventoryPlayer inventory)
{
Listeners listeners = this.listeners.get(player.getAdvancements());
if (listeners != null)
{
listeners.trigger(inventory);
}
}
public static class Instance extends AbstractCriterionInstance
{
public Instance()
{
super(ID);
}
}
static class Listeners
{
private final PlayerAdvancements playerAdvancements;
private final Set<Listener<Instance>> listeners = new HashSet<>();
public Listeners(PlayerAdvancements playerAdvancementsIn)
{
this.playerAdvancements = playerAdvancementsIn;
}
public boolean isEmpty()
{
return this.listeners.isEmpty();
}
public void add(ICriterionTrigger.Listener<Instance> listener)
{
this.listeners.add(listener);
}
public void remove(ICriterionTrigger.Listener<Instance> listener)
{
this.listeners.remove(listener);
}
public void trigger(InventoryPlayer inventory)
{
List<Listener<Instance>> list = null;
for (ICriterionTrigger.Listener<Instance> listener : this.listeners)
{
if (ENABLED)
{
if (list == null)
{
list = new ArrayList<>();
}
list.add(listener);
}
}
if (list != null)
{
for (ICriterionTrigger.Listener<Instance> listener1 : list)
{
listener1.grantCriterion(this.playerAdvancements);
}
}
}
}
}
}
*/

View File

@ -1,25 +0,0 @@
/*
* Minecraft Forge
* Copyright (c) 2016-2019.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation version 2.1
* of the License.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
@ParametersAreNonnullByDefault
@MethodsReturnNonnullByDefault
package net.minecraftforge.debug.gameplay.advancement;
import javax.annotation.ParametersAreNonnullByDefault;
import mcp.MethodsReturnNonnullByDefault;

View File

@ -1,128 +0,0 @@
/*
* Minecraft Forge
* Copyright (c) 2016-2019.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation version 2.1
* of the License.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
/*
package net.minecraftforge.debug.gameplay.loot;
import java.util.Random;
import com.google.gson.JsonDeserializationContext;
import com.google.gson.JsonObject;
import com.google.gson.JsonSerializationContext;
import com.google.gson.JsonSyntaxException;
import net.minecraft.init.Biomes;
import net.minecraft.init.Items;
import net.minecraft.util.ResourceLocation;
import net.minecraft.world.biome.Biome;
import net.minecraft.world.storage.loot.LootContext;
import net.minecraft.world.storage.loot.LootEntryItem;
import net.minecraft.world.storage.loot.LootPool;
import net.minecraft.world.storage.loot.LootTableList;
import net.minecraft.world.storage.loot.RandomValueRange;
import net.minecraft.world.storage.loot.conditions.EntityHasProperty;
import net.minecraft.world.storage.loot.conditions.LootCondition;
import net.minecraft.world.storage.loot.conditions.LootConditionManager;
import net.minecraft.world.storage.loot.functions.LootFunction;
import net.minecraft.world.storage.loot.functions.SetCount;
import net.minecraft.world.storage.loot.properties.EntityOnFire;
import net.minecraft.world.storage.loot.properties.EntityProperty;
import net.minecraftforge.event.LootTableLoadEvent;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.Mod.EventBusSubscriber;
import net.minecraftforge.fml.event.FMLPreInitializationEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.registry.ForgeRegistries;
//@EventBusSubscriber
//@Mod(modid = LootContextTweaksTest.MODID, name = "LootContextTweaksTest", version = "1.0", acceptableRemoteVersions = "*")
public class LootContextTweaksTest
{
public static final String MODID = "loot_context_tweaks_test";
public static final boolean ENABLED = false;
@Mod.EventHandler
public void preInit(FMLPreInitializationEvent event)
{
if (!ENABLED) return;
LootConditionManager.registerCondition(new InBiome.Serialiser());
}
@net.minecraftforge.eventbus.api.SubscribeEvent
public static void onLootTableLoad(LootTableLoadEvent event)
{
if (!ENABLED) return;
if (event.getName().equals(LootTableList.GAMEPLAY_FISHING))
{
LootPool main = event.getTable().getPool("main");
main.addEntry(new LootEntryItem(Items.ACACIA_BOAT, 100, 1, new LootFunction[0], new LootCondition[] {new InBiome(Biomes.SAVANNA)}, "fishing_test"));
}
else if (event.getName().equals(LootTableList.CHESTS_SIMPLE_DUNGEON))
{
LootPool main = event.getTable().getPool("main");
LootCondition onFire = new EntityHasProperty(new EntityProperty[] {new EntityOnFire(true)}, LootContext.EntityTarget.KILLER_PLAYER);
main.addEntry(new LootEntryItem(Items.BLAZE_POWDER, 100, 1, new LootFunction[] {new SetCount(new LootCondition[0], new RandomValueRange(64))}, new LootCondition[] {onFire}, "minecart_test"));
}
}
private static class InBiome implements LootCondition
{
private final Biome requiredBiome;
public InBiome(Biome requiredBiome)
{
this.requiredBiome = requiredBiome;
}
@Override
public boolean testCondition(Random rand, LootContext context)
{
if (context.getLootedEntity() == null) return false;
Biome biome = context.getWorld().getBiome(context.getLootedEntity().getPosition());
return biome == requiredBiome;
}
private static class Serialiser extends LootCondition.Serializer<InBiome>
{
protected Serialiser()
{
super(new ResourceLocation(MODID, "in_biome"), InBiome.class);
}
@Override
public void serialize(JsonObject json, InBiome value, JsonSerializationContext context)
{
json.addProperty("biome", value.requiredBiome.getRegistryName().toString());
}
@Override
public InBiome deserialize(JsonObject json, JsonDeserializationContext context)
{
if (!json.has("biome")) throw new JsonSyntaxException("Missing biome tag, expected to find a biome registry name");
ResourceLocation biomeResLoc = new ResourceLocation(json.get("biome").getAsString());
Biome biome = ForgeRegistries.BIOMES.getValue(biomeResLoc);
if (biome == null) throw new JsonSyntaxException("Invalid biome tag. " + biomeResLoc + " does not exist in the biome registry.");
return new InBiome(biome);
}
}
}
}
*/

View File

@ -1,61 +0,0 @@
/*
* Minecraft Forge
* Copyright (c) 2016-2019.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation version 2.1
* of the License.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
/*
package net.minecraftforge.debug.gameplay.loot;
import net.minecraft.util.ResourceLocation;
import net.minecraft.world.storage.loot.LootTable;
import net.minecraft.world.storage.loot.LootTableList;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.LootTableLoadEvent;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.Mod.EventHandler;
import net.minecraftforge.fml.event.FMLInitializationEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
//@Mod(modid = LootTableLoadEventTest.MODID, name = "LootTableLoadEventTest", version = "1.0", acceptableRemoteVersions = "*")
public class LootTableLoadEventTest
{
public static final boolean ENABLED = false;
public static final String MODID = "loottable_load_event_test";
@EventHandler
public void init(FMLInitializationEvent event)
{
if (ENABLED)
{
MinecraftForge.EVENT_BUS.register(this);
}
}
@net.minecraftforge.eventbus.api.SubscribeEvent
public void onLootTableLoadEvent(LootTableLoadEvent event)
{
if (LootTableList.CHESTS_SPAWN_BONUS_CHEST.equals(event.getName()))
{
ResourceLocation loc = new ResourceLocation(MODID, "chests/custom_spawn_bonus_chest");
LootTable customLootTable = event.getLootTableManager().getLootTableFromLocation(loc);
event.setTable(customLootTable);
}
}
}
*/

View File

@ -1,81 +0,0 @@
/*
* Minecraft Forge
* Copyright (c) 2016-2019.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation version 2.1
* of the License.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
/*
package net.minecraftforge.debug.gameplay.loot;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.projectile.EntityArrow;
import net.minecraft.init.Items;
import net.minecraft.util.DamageSource;
import net.minecraft.world.storage.loot.LootEntryItem;
import net.minecraft.world.storage.loot.LootPool;
import net.minecraft.world.storage.loot.LootTableList;
import net.minecraft.world.storage.loot.conditions.LootCondition;
import net.minecraft.world.storage.loot.functions.LootFunction;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.LootTableLoadEvent;
import net.minecraftforge.event.entity.living.LootingLevelEvent;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.event.FMLInitializationEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
//@Mod(modid = LootTableTest.MODID, name = "Loot Table Debug", version = "1.0", acceptableRemoteVersions = "*")
public class LootTableTest
{
public static final String MODID = "loot_table_debug";
@Mod.EventHandler
public void init(FMLInitializationEvent event)
{
MinecraftForge.EVENT_BUS.register(this);
}
@net.minecraftforge.eventbus.api.SubscribeEvent
public void lootLoad(LootTableLoadEvent event)
{
if (!event.getName().equals(LootTableList.CHESTS_SPAWN_BONUS_CHEST))
{
return;
}
// Remove axes and replace with chestpeice, First vanilla entry is always called "main"
LootPool main = event.getTable().getPool("main"); //Note: This CAN NPE if another mod removes things
main.removeEntry("minecraft:wooden_axe");
main.removeEntry("minecraft:stone_axe");
main.addEntry(new LootEntryItem(Items.DIAMOND_CHESTPLATE, 1, 0, new LootFunction[0], new LootCondition[0], MODID + ":diamond_chestplate"));
// Get rid of all building mats. Which is pool #3, index starts at 0, but 0 is named "main"
event.getTable().removePool("pool3");
}
@net.minecraftforge.eventbus.api.SubscribeEvent
public void lootingEvent(LootingLevelEvent event)
{
// if the player shoots something with a projectile, use looting 3
DamageSource damageSource = event.getDamageSource();
if (damageSource.isProjectile() && damageSource.getTrueSource() instanceof EntityPlayer && damageSource.getImmediateSource() instanceof EntityArrow)
{
event.setLootingLevel(3);
}
}
}
*/

View File

@ -1,25 +0,0 @@
/*
* Minecraft Forge
* Copyright (c) 2016-2019.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation version 2.1
* of the License.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
@ParametersAreNonnullByDefault
@MethodsReturnNonnullByDefault
package net.minecraftforge.debug.gameplay;
import javax.annotation.ParametersAreNonnullByDefault;
import mcp.MethodsReturnNonnullByDefault;

View File

@ -1,75 +0,0 @@
/*
* Minecraft Forge
* Copyright (c) 2016-2019.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation version 2.1
* of the License.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
/*
package net.minecraftforge.debug.item;
import net.minecraft.util.EnumHand;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.entity.player.BonemealEvent;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.event.FMLPreInitializationEvent;
import net.minecraftforge.eventbus.api.Event;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import org.apache.logging.log4j.Logger;
//@Mod(modid = BonemealEventTest.MODID, name = "Bonemeal Event Test", version = "1.0", acceptableRemoteVersions = "*")
public class BonemealEventTest
{
public static final String MODID = "bonemealeventtest";
private static final boolean ENABLED = false;
private static Logger logger;
@Mod.EventHandler
public void preInit(FMLPreInitializationEvent event)
{
logger = event.getModLog();
if (ENABLED)
{
MinecraftForge.EVENT_BUS.register(BonemealEventTest.class);
}
}
@SubscribeEvent
public static void onBonemeal(BonemealEvent event)
{
if (event.getHand() == EnumHand.MAIN_HAND)
{
// If the bone meal is being used from the main hand, set the result to ALLOW to use up the bone meal without growing the crop
event.setResult(net.minecraftforge.eventbus.api.Event.Result.ALLOW);
logger.info("Prevented bone meal growth effect from main hand");
}
else if (event.getHand() == EnumHand.OFF_HAND)
{
// If the bone meal is being used from the off hand, cancel the event to prevent it being used at all
event.setCanceled(true);
logger.info("Prevented bone meal use from off hand");
}
else
{
// If the bone meal is being used from a dispenser or something similar, allow it
logger.info("Allowed bone meal use from dispenser");
}
}
}
*/

View File

@ -1,92 +0,0 @@
/*
* Minecraft Forge
* Copyright (c) 2016-2019.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation version 2.1
* of the License.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
/*
package net.minecraftforge.debug.item;
import net.minecraft.client.renderer.model.ModelBakery;
import net.minecraft.enchantment.Enchantment;
import net.minecraft.init.Enchantments;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.client.event.ModelRegistryEvent;
import net.minecraftforge.event.RegistryEvent;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.eventbus.api.SubscribeEvent;
//@Mod(modid = CanApplyAtEnchantingTableTest.MODID, name = "CanApplyAtEnchantingTableTest", version = "0.0.0", acceptableRemoteVersions = "*")
public class CanApplyAtEnchantingTableTest
{
public static final String MODID = "can_apply_at_enchanting_table_test";
public static final boolean ENABLE = false;
public static final Item testItem = new Item()
{
@Override
public boolean isEnchantable(ItemStack stack)
{
return true;
}
@Override
public int getItemEnchantability()
{
return 30;
}
@Override
public boolean canApplyAtEnchantingTable(ItemStack stack, Enchantment enchantment)
{
return super.canApplyAtEnchantingTable(stack, enchantment) || enchantment == Enchantments.FORTUNE;
}
};
//@Mod.EventBusSubscriber(modid = MODID)
public static class Registration
{
@SubscribeEvent
public static void registerItems(RegistryEvent.Register<Item> event)
{
if (ENABLE)
{
event.getRegistry().register(
testItem.setRegistryName("test_item")
.setUnlocalizedName("FortuneEnchantableOnly")
.setMaxStackSize(1));
}
}
}
//@Mod.EventBusSubscriber(value = Side.CLIENT, modid = MODID)
public static class ClientEventHandler
{
@net.minecraftforge.eventbus.api.SubscribeEvent
public static void registerModels(ModelRegistryEvent event)
{
if (ENABLE)
{
ModelBakery.registerItemVariants(testItem);
}
}
}
}
*/

View File

@ -1,65 +0,0 @@
/*
* Minecraft Forge
* Copyright (c) 2016-2019.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation version 2.1
* of the License.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
/*
package net.minecraftforge.debug.item;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.event.RegistryEvent;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.eventbus.api.SubscribeEvent;
//@Mod(modid = CanDestroyBlocksInCreativeTest.MODID, name = "Item.canDestroyBlockInCreative() Test", version = "1.0", acceptableRemoteVersions = "*")
public class CanDestroyBlocksInCreativeTest
{
public static final boolean ENABLE = true;
public static final String MODID = "item_can_destroy_blocks_in_creative_test";
//@Mod.EventBusSubscriber(modid = MODID)
public static class Registration
{
@SubscribeEvent
public static void registerItems(RegistryEvent.Register<Item> event)
{
if (!ENABLE)
return;
Item test = new Item()
{
@Override
public boolean canDestroyBlockInCreative(World world, BlockPos pos, ItemStack stack, EntityPlayer player)
{
return false;
}
}.setRegistryName(MODID, "item_test")
.setUnlocalizedName(MODID + ".item_test")
.setCreativeTab(CreativeTabs.TOOLS);
event.getRegistry().register(test);
}
}
}
*/

View File

@ -1,137 +0,0 @@
/*
* Minecraft Forge
* Copyright (c) 2016-2019.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation version 2.1
* of the License.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
/*
package net.minecraftforge.debug.item;
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.EnumAction;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ActionResult;
import net.minecraft.util.EnumActionResult;
import net.minecraft.util.EnumHand;
import net.minecraft.world.World;
import net.minecraftforge.client.event.ModelRegistryEvent;
import net.minecraftforge.client.model.ModelLoader;
import net.minecraftforge.event.RegistryEvent;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.common.registry.GameRegistry;
import net.minecraftforge.fml.relauncher.Side;
//@Mod(modid = ContinuousUseItemTest.MOD_ID, name = "Test for canContinueUsing", version = "1.0", acceptableRemoteVersions = "*")
//@Mod.EventBusSubscriber
public class ContinuousUseItemTest
{
static final String MOD_ID = "continuous_use_item_test";
static final boolean ENABLED = false;
@GameRegistry.ObjectHolder(TestItem.NAME)
public static final Item TEST_ITEM = null;
@SubscribeEvent
public static void registerItem(RegistryEvent.Register<Item> event)
{
if (ENABLED)
{
event.getRegistry().register(
new TestItem().setRegistryName(MOD_ID, TestItem.NAME)
.setUnlocalizedName(MOD_ID + "." + TestItem.NAME)
.setCreativeTab(CreativeTabs.MISC)
);
}
}
@Mod.EventBusSubscriber(value = Side.CLIENT, modid = MOD_ID)
public static class ClientEventHandler
{
@SubscribeEvent
public static void registerModels(ModelRegistryEvent event)
{
if (ENABLED)
{
ModelLoader.setCustomModelResourceLocation(TEST_ITEM, 0, new ModelResourceLocation("minecraft:stick", "inventory"));
}
}
}
static class TestItem extends Item
{
static final String NAME = "test_item";
TestItem()
{
maxStackSize = 1;
setMaxDamage(60);
}
@Override
public boolean hasEffect(ItemStack stack)
{
return true;
}
@Override
public EnumAction getItemUseAction(ItemStack stack)
{
return EnumAction.BOW;
}
@Override
public int getMaxItemUseDuration(ItemStack stack)
{
return 72000;
}
@Override
public ActionResult<ItemStack> onItemRightClick(World worldIn, EntityPlayer playerIn, EnumHand handIn)
{
playerIn.setActiveHand(handIn);
return new ActionResult<>(EnumActionResult.SUCCESS, playerIn.getHeldItem(handIn));
}
@Override
public void onUsingTick(ItemStack stack, EntityLivingBase living, int count)
{
if (count % 10 == 0)
{
stack.damageItem(1, living);
}
}
@Override
public boolean shouldCauseReequipAnimation(ItemStack oldStack, ItemStack newStack, boolean slotChanged)
{
return slotChanged || oldStack.getItem() != newStack.getItem();
}
@Override
public boolean canContinueUsing(ItemStack oldStack, ItemStack newStack)
{
return oldStack.getItem() == newStack.getItem();
}
}
}
*/

View File

@ -1,102 +0,0 @@
/*
* Minecraft Forge
* Copyright (c) 2016-2019.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation version 2.1
* of the License.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
/*
package net.minecraftforge.debug.item;
import net.minecraft.client.renderer.model.ModelResourceLocation;
import net.minecraft.entity.EntityLiving;
import net.minecraft.entity.passive.HorseArmorType;
import net.minecraft.init.MobEffects;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.potion.PotionEffect;
import net.minecraft.world.World;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.client.event.ModelRegistryEvent;
import net.minecraftforge.client.model.ModelLoader;
import net.minecraftforge.common.util.EnumHelper;
import net.minecraftforge.event.RegistryEvent;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.Mod.EventBusSubscriber;
import net.minecraftforge.fml.event.FMLPreInitializationEvent;
import net.minecraftforge.fml.common.registry.GameRegistry.ObjectHolder;
//@EventBusSubscriber
//@Mod(modid = HorseArmorTest.MODID, name = "HorseArmorTest", version = "1.0", acceptableRemoteVersions = "*")
public class HorseArmorTest
{
public static final String MODID = "horse_armor_test";
public static final boolean ENABLED = true;
public static HorseArmorType testArmorType;
@ObjectHolder("test_armor")
public static final ItemTestHorseArmor TEST_ARMOR = null;
@Mod.EventHandler
public void preInit(FMLPreInitializationEvent event)
{
if(ENABLED)
testArmorType = EnumHelper.addHorseArmor("test", MODID + ":textures/entity/horse/armor/test.png", 15);
}
@net.minecraftforge.eventbus.api.SubscribeEvent
public static void registerItems(RegistryEvent.Register<Item> event)
{
if(ENABLED)
event.getRegistry().register(new ItemTestHorseArmor().setRegistryName(MODID, "test_armor").setUnlocalizedName(MODID + ".testArmor"));
}
//@EventBusSubscriber(modid = MODID, value = Side.CLIENT)
public static class ClientEventHandler
{
@net.minecraftforge.eventbus.api.SubscribeEvent
public static void registerModels(ModelRegistryEvent event)
{
if(ENABLED)
ModelLoader.setCustomModelResourceLocation(TEST_ARMOR, 0, new ModelResourceLocation(TEST_ARMOR.getRegistryName(), "inventory"));
}
}
private static class ItemTestHorseArmor extends Item
{
@Override
public HorseArmorType getHorseArmorType(ItemStack stack)
{
return testArmorType;
}
@Override
public String getHorseArmorTexture(EntityLiving wearer, ItemStack stack)
{
return stack.isItemEnchanted() ? HorseArmorType.IRON.getTextureName() : super.getHorseArmorTexture(wearer, stack);
}
@Override
public void onHorseArmorTick(World world, EntityLiving wearer, ItemStack itemStack)
{
if(wearer.ticksExisted % 15 == 0)
wearer.addPotionEffect(new PotionEffect(MobEffects.GLOWING, 20, 1));
}
}
}
*/

View File

@ -1,103 +0,0 @@
/*
* Minecraft Forge
* Copyright (c) 2016-2019.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation version 2.1
* of the License.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
/*
package net.minecraftforge.debug.item;
import net.minecraft.client.renderer.model.ModelBakery;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.enchantment.Enchantment;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.client.event.ModelRegistryEvent;
import net.minecraftforge.event.RegistryEvent;
import net.minecraftforge.fml.common.Mod;
//@Mod(modid = IsBookEnchantableTest.MOD_ID, name = "Test for isBookEnchantable", version = "1.0", acceptableRemoteVersions = "*")
//@Mod.EventBusSubscriber
public class IsBookEnchantableTest
{
public static final boolean ENABLED = false;
static final String MOD_ID = "is_book_enchantable_test";
private static final Item TEST_ITEM = new TestItem();
@net.minecraftforge.eventbus.api.SubscribeEvent
public static void registerItem(RegistryEvent.Register<Item> event)
{
if (ENABLED)
{
event.getRegistry().register(TEST_ITEM);
}
}
//@Mod.EventBusSubscriber(value = Side.CLIENT, modid = MOD_ID)
public static class ClientEventHandler
{
@net.minecraftforge.eventbus.api.SubscribeEvent
public static void registerModels(ModelRegistryEvent event)
{
if (ENABLED)
{
ModelBakery.registerItemVariants(TEST_ITEM);
}
}
}
private static class TestItem extends Item
{
private static final String NAME = "test_item";
private TestItem()
{
maxStackSize = 1;
setUnlocalizedName(MOD_ID + "." + NAME);
setRegistryName(NAME);
setCreativeTab(CreativeTabs.MISC);
}
@Override
public boolean isEnchantable(ItemStack stack)
{
return true;
}
@Override
public int getItemEnchantability()
{
return 15;
}
@Override
public boolean isBookEnchantable(ItemStack stack, ItemStack book)
{
return false;
}
@Override
public boolean canApplyAtEnchantingTable(ItemStack stack, Enchantment enchantment)
{
return true;
}
}
}
*/

View File

@ -1,69 +0,0 @@
/*
* Minecraft Forge
* Copyright (c) 2016-2019.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation version 2.1
* of the License.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
/*
package net.minecraftforge.debug.item;
import net.minecraft.entity.projectile.EntityFishHook;
import net.minecraft.init.Biomes;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.biome.Biome;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.entity.player.ItemFishedEvent;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.event.FMLPreInitializationEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import org.apache.logging.log4j.Logger;
//@Mod(modid = "itemfishtest", name = "ItemFishTest", version = "1.0.0", acceptableRemoteVersions = "*")
public class ItemFishedEventTest
{
private static final boolean ENABLE = false;
private static Logger logger;
@Mod.EventHandler
public void onInit(FMLPreInitializationEvent event)
{
if (ENABLE)
{
logger = event.getModLog();
logger.info("Enabling Fishing Test mod");
MinecraftForge.EVENT_BUS.register(this);
}
}
@net.minecraftforge.eventbus.api.SubscribeEvent
public void onItemFished(ItemFishedEvent event)
{
EntityFishHook hook = event.getHookEntity();
BlockPos bobberPos = hook.getPosition();
Biome biomeFishedAt = hook.getEntityWorld().getBiome(bobberPos);
logger.info("Item fished in Biome {}", biomeFishedAt.getBiomeName());
if (biomeFishedAt.equals(Biomes.OCEAN))
{
logger.info("Canceling the event because biome is ocean");
event.setCanceled(true);
}
event.damageRodBy(50);
}
}
*/

View File

@ -1,278 +0,0 @@
/*
* Minecraft Forge
* Copyright (c) 2016-2019.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation version 2.1
* of the License.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
/*
package net.minecraftforge.debug.item;
import io.netty.buffer.ByteBuf;
import net.minecraft.block.material.MapColor;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.MapItemRenderer;
import net.minecraft.client.renderer.model.ModelBakery;
import net.minecraft.client.renderer.model.ModelResourceLocation;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemMap;
import net.minecraft.item.ItemMapBase;
import net.minecraft.item.ItemStack;
import net.minecraft.network.Packet;
import net.minecraft.network.PacketBuffer;
import net.minecraft.network.play.server.SPacketMaps;
import net.minecraft.stats.StatList;
import net.minecraft.util.ActionResult;
import net.minecraft.util.EnumActionResult;
import net.minecraft.util.EnumHand;
import net.minecraft.world.World;
import net.minecraft.world.storage.MapData;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.client.event.ModelRegistryEvent;
import net.minecraftforge.client.model.ModelLoader;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.RegistryEvent;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.event.FMLPreInitializationEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.network.simpleimpl.IMessage;
import net.minecraftforge.fml.common.network.simpleimpl.IMessageHandler;
import net.minecraftforge.fml.network.NetworkEvent;
import net.minecraftforge.fml.common.network.simpleimpl.SimpleNetworkWrapper;
import net.minecraftforge.fml.common.registry.GameRegistry;
import javax.annotation.Nullable;
import java.io.IOException;
import java.util.Arrays;
//@Mod(modid = "mapdatatest", name = "mapdatatest", version = "1.0", acceptableRemoteVersions = "*")
public class MapDataTest
{
@GameRegistry.ObjectHolder("mapdatatest:custom_map")
public static final Item CUSTOM_MAP = null;
@GameRegistry.ObjectHolder("mapdatatest:empty_custom_map")
public static final Item EMPTY_CUSTOM_MAP = null;
private static SimpleNetworkWrapper packetHandler;
@Mod.EventHandler
public void preInit(FMLPreInitializationEvent evt)
{
packetHandler = new SimpleNetworkWrapper("mapdatatest");
packetHandler.registerMessage(CustomMapPacketHandler.class, CustomMapPacket.class, 0, Side.CLIENT);
MinecraftForge.EVENT_BUS.register(this);
}
@SubscribeEvent
public void registerModels(ModelRegistryEvent evt)
{
ModelLoader.setCustomModelResourceLocation(EMPTY_CUSTOM_MAP, 0, new ModelResourceLocation("map", "inventory"));
ModelLoader.setCustomMeshDefinition(CUSTOM_MAP, s -> new ModelResourceLocation("filled_map", "inventory"));
ModelBakery.registerItemVariants(CUSTOM_MAP, new ModelResourceLocation("filled_map", "inventory"));
}
@SubscribeEvent
public void registerItems(RegistryEvent.Register<Item> evt)
{
evt.getRegistry().register(new EmptyCustomMap().setUnlocalizedName("emptyCustomMap").setRegistryName("mapdatatest", "empty_custom_map"));
evt.getRegistry().register(new CustomMap().setUnlocalizedName("customMap").setRegistryName("mapdatatest", "custom_map"));
}
public static class EmptyCustomMap extends ItemMapBase
{
// copy of super, setting up our own map
@Override
public ActionResult<ItemStack> onItemRightClick(World worldIn, EntityPlayer playerIn, EnumHand handIn)
{
ItemStack itemstack = CustomMap.setupNewMap(worldIn, playerIn.posX, playerIn.posZ, (byte) 0, true, false);
ItemStack itemstack1 = playerIn.getHeldItem(handIn);
itemstack1.shrink(1);
if (itemstack1.isEmpty())
{
return new ActionResult<>(EnumActionResult.SUCCESS, itemstack);
} else
{
if (!playerIn.inventory.addItemStackToInventory(itemstack.copy()))
{
playerIn.dropItem(itemstack, false);
}
playerIn.addStat(StatList.getObjectUseStats(this));
return new ActionResult<>(EnumActionResult.SUCCESS, itemstack1);
}
}
}
public static class CustomMap extends ItemMap
{
private static final String PREFIX = "custommap";
// copy of super with own map prefix
public static ItemStack setupNewMap(World worldIn, double worldX, double worldZ, byte scale, boolean trackingPosition, boolean unlimitedTracking)
{
ItemStack itemstack = new ItemStack(CUSTOM_MAP, 1, worldIn.getUniqueDataId(PREFIX));
String s = PREFIX + "_" + itemstack.getMetadata();
MapData mapdata = new CustomMapData(s);
worldIn.setData(s, mapdata);
mapdata.scale = scale;
mapdata.calculateMapCenter(worldX, worldZ, mapdata.scale);
mapdata.dimension = worldIn.provider.getDimension();
mapdata.trackingPosition = trackingPosition;
mapdata.unlimitedTracking = unlimitedTracking;
mapdata.markDirty();
return itemstack;
}
// copy of super with own map prefix and type
@Nullable
@OnlyIn(Dist.CLIENT)
public static CustomMapData loadMapData(int mapId, World worldIn)
{
String s = PREFIX + "_" + mapId;
return (CustomMapData) worldIn.loadData(CustomMapData.class, s);
}
// copy of super with own map prefix and type
@Nullable
@Override
public CustomMapData getMapData(ItemStack stack, World worldIn)
{
String s = PREFIX + "_" + stack.getMetadata();
CustomMapData mapdata = (CustomMapData) worldIn.loadData(CustomMapData.class, s);
if (mapdata == null && !worldIn.isRemote)
{
stack.setItemDamage(worldIn.getUniqueDataId(PREFIX));
s = PREFIX + "_" + stack.getMetadata();
mapdata = new CustomMapData(s);
mapdata.scale = 3;
mapdata.calculateMapCenter((double) worldIn.getWorldInfo().getSpawnX(), (double) worldIn.getWorldInfo().getSpawnZ(), mapdata.scale);
mapdata.dimension = worldIn.provider.getDimension();
mapdata.markDirty();
worldIn.setData(s, mapdata);
}
return mapdata;
}
@Override
public void updateMapData(World worldIn, Entity viewer, MapData data)
{
// Solid red
Arrays.fill(data.colors, (byte) (MapColor.RED.colorIndex * 4 + 1));
}
// rewrap vanilla packet with own, to sync CustomMapData's extra data
@Override
public Packet<?> createMapDataPacket(ItemStack stack, World worldIn, EntityPlayer player)
{
SPacketMaps vanillaPacket = (SPacketMaps) super.createMapDataPacket(stack, worldIn, player);
if (vanillaPacket == null)
{
return null;
}
return packetHandler.getPacketFrom(new CustomMapPacket(vanillaPacket));
}
}
// A custom subclass to distinguish from vanilla's type in the WorldSavedData
public static class CustomMapData extends MapData
{
public CustomMapData(String mapname)
{
super(mapname);
}
}
// Custom map packet wrapping vanilla's because the handler needs to use our custom type
public static class CustomMapPacket implements IMessage
{
public SPacketMaps vanillaPacket;
public CustomMapPacket() {}
public CustomMapPacket(SPacketMaps vanillaPacket)
{
this.vanillaPacket = vanillaPacket;
}
@Override
public void fromBytes(ByteBuf buf) {
vanillaPacket = new SPacketMaps();
try {
vanillaPacket.readPacketData(new PacketBuffer(buf));
} catch (IOException e) {
e.printStackTrace();
}
}
@Override
public void toBytes(ByteBuf buf) {
try {
vanillaPacket.writePacketData(new PacketBuffer(buf));
} catch (IOException e) {
e.printStackTrace();
}
}
}
public static class CustomMapPacketHandler implements IMessageHandler<CustomMapPacket, IMessage>
{
@Nullable
@Override
public IMessage onMessage(CustomMapPacket message, NetworkEvent.Context ctx)
{
// Like NetHandlerPlayClient.handleMaps but using our custom type
Minecraft.getMinecraft().addScheduledTask(new Runnable() {
@Override
public void run()
{
MapItemRenderer mapitemrenderer = Minecraft.getMinecraft().entityRenderer.getMapItemRenderer();
MapData mapdata = CustomMap.loadMapData(message.vanillaPacket.getMapId(), Minecraft.getMinecraft().world);
if (mapdata == null) {
String s = CustomMap.PREFIX + "_" + message.vanillaPacket.getMapId();
mapdata = new CustomMapData(s);
if (mapitemrenderer.getMapInstanceIfExists(s) != null) {
MapData mapdata1 = mapitemrenderer.getData(mapitemrenderer.getMapInstanceIfExists(s));
if (mapdata1 != null) {
mapdata = mapdata1;
}
}
Minecraft.getMinecraft().world.setData(s, mapdata);
}
message.vanillaPacket.setMapdataTo(mapdata);
mapitemrenderer.updateMapTexture(mapdata);
}
});
return null;
}
}
}
*/

View File

@ -1,98 +0,0 @@
/*
* Minecraft Forge
* Copyright (c) 2016-2019.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation version 2.1
* of the License.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
/*
package net.minecraftforge.debug.item;
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.init.Enchantments;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.NonNullList;
import net.minecraftforge.client.event.ModelRegistryEvent;
import net.minecraftforge.client.model.ModelLoader;
import net.minecraftforge.event.RegistryEvent;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.common.registry.GameRegistry;
import net.minecraftforge.fml.relauncher.Side;
//@Mod.EventBusSubscriber
//@Mod(modid = MendingRepairTest.MOD_ID, name = "Mending repair amount test mod", version = "1.0")
public class MendingRepairTest
{
static final boolean ENABLED = true;
static final String MOD_ID = "mending_repair_test";
@GameRegistry.ObjectHolder(MOD_ID + ":test_item")
public static final Item TEST_ITEM = null;
@SubscribeEvent
public static void registerItems(RegistryEvent.Register<Item> event)
{
if (!ENABLED) return;
event.getRegistry().register(
new TestItem()
.setRegistryName(MOD_ID, "test_item")
.setUnlocalizedName(MOD_ID + ".test_item")
);
}
@Mod.EventBusSubscriber(modid = MOD_ID, value = Side.CLIENT)
public static final class ClientEventHandler
{
@SubscribeEvent
public static void registerModels(ModelRegistryEvent event)
{
if (!ENABLED) return;
ModelLoader.setCustomModelResourceLocation(TEST_ITEM, 0, new ModelResourceLocation("minecraft:blaze_rod", "inventory"));
}
}
private static final class TestItem extends Item
{
TestItem()
{
maxStackSize = 1;
setMaxDamage(10);
setCreativeTab(CreativeTabs.TOOLS);
}
@Override
public void getSubItems(CreativeTabs tab, NonNullList<ItemStack> items)
{
if (this.isInCreativeTab(tab))
{
ItemStack stack = new ItemStack(this);
stack.addEnchantment(Enchantments.MENDING, 1);
stack.setItemDamage(stack.getMaxDamage());
items.add(stack);
}
}
@Override
public float getXpRepairRatio(ItemStack stack)
{
return 0.1f;
}
}
}*/

View File

@ -1,133 +0,0 @@
/*
* Minecraft Forge
* Copyright (c) 2016-2019.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation version 2.1
* of the License.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
/*
package net.minecraftforge.debug.item;
import net.minecraft.client.renderer.model.ModelResourceLocation;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.IRecipe;
import net.minecraft.item.crafting.Ingredient;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.NonNullList;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.client.event.ModelRegistryEvent;
import net.minecraftforge.client.model.ModelLoader;
import net.minecraftforge.event.RegistryEvent;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.registry.GameRegistry;
import net.minecraftforge.fml.common.registry.GameRegistry.ObjectHolder;
import javax.annotation.Nullable;
//@Mod(modid = NBTShareTagTest.MODID, name = "NBTShareTag Item Test", version = "1.0.0", acceptableRemoteVersions = "*")
public class NBTShareTagTest
{
public static final String MODID = "nbtsharetagitemtest";
private static final ResourceLocation itemName = new ResourceLocation(MODID, "nbt_share_tag_item");
@ObjectHolder("nbt_share_tag_item")
public static final Item TEST_ITEM = null;
//@Mod.EventBusSubscriber(modid = MODID)
public static class Registration
{
@net.minecraftforge.eventbus.api.SubscribeEvent
public static void registerRecipes(RegistryEvent.Register<IRecipe> event)
{
ItemStack crafted = new ItemStack(TEST_ITEM);
NBTTagCompound nbt = new NBTTagCompound();
nbt.setBoolean("crafted", true);
crafted.setTagCompound(nbt);
GameRegistry.addShapelessRecipe(new ResourceLocation(MODID, "nbt_share"), null, crafted, Ingredient.fromItem(Items.STICK));
}
@net.minecraftforge.eventbus.api.SubscribeEvent
public static void registerItems(RegistryEvent.Register<Item> event)
{
event.getRegistry().register(new ShareTagItem().setRegistryName(itemName));
}
@net.minecraftforge.eventbus.api.SubscribeEvent
public static void registerModels(ModelRegistryEvent event)
{
ModelLoader.setCustomModelResourceLocation(TEST_ITEM, 0, new ModelResourceLocation(itemName, "inventory"));
}
}
public static class ShareTagItem extends Item
{
public ShareTagItem()
{
setCreativeTab(CreativeTabs.MISC);
}
@Nullable
@Override
public NBTTagCompound getNBTShareTag(ItemStack stack)
{
NBTTagCompound networkNBT = stack.getTagCompound();
if (networkNBT == null)
networkNBT = new NBTTagCompound();
networkNBT.setBoolean("nbtShareTag", true);
return networkNBT;
}
@Override
public void getSubItems(CreativeTabs tab, NonNullList<ItemStack> subItems)
{
if (!this.isInCreativeTab(tab))
return;
ItemStack creativeMenuItem = new ItemStack(this);
NBTTagCompound creativeMenuNBT = new NBTTagCompound();
creativeMenuNBT.setBoolean("creativeMenu", true);
creativeMenuItem.setTagCompound(creativeMenuNBT);
subItems.add(creativeMenuItem);
}
@Override
public String getItemStackDisplayName(ItemStack stack)
{
NBTTagCompound tagCompound = stack.getTagCompound();
String name = "NBTShareTagItem: ";
if (tagCompound == null)
{
name += "From /give. ";
}
else
{
if (tagCompound.getBoolean("nbtShareTag"))
name += "Sent from server. ";
if (tagCompound.getBoolean("creativeMenu"))
name += "From creative menu. ";
if (tagCompound.getBoolean("crafted"))
name += "From crafting. ";
}
return name;
}
}
}
*/

View File

@ -1,120 +0,0 @@
/*
* Minecraft Forge
* Copyright (c) 2016-2019.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation version 2.1
* of the License.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
/*
package net.minecraftforge.debug.item;
import net.minecraft.client.renderer.model.ModelResourceLocation;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.*;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.text.TextComponentString;
import net.minecraft.world.World;
import net.minecraftforge.client.model.ModelLoader;
import net.minecraftforge.event.RegistryEvent;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import javax.annotation.Nonnull;
//@Mod(modid = OnItemUseFirstTest.MODID, name = "OnItemUseFirstTest", version = "0.0.0", acceptableRemoteVersions = "*")
//@Mod.EventBusSubscriber
public class OnItemUseFirstTest
{
public static final boolean ENABLE = true;
public static final String MODID = "onitemusefirsttest";
public static CommonProxy proxy = null;
public static abstract class CommonProxy
{
public void registerItem(RegistryEvent.Register<Item> event)
{
ItemTest.instance = new ItemTest().setCreativeTab(CreativeTabs.MISC);
event.getRegistry().register(ItemTest.instance);
}
}
public static final class ServerProxy extends CommonProxy
{
}
public static final class ClientProxy extends CommonProxy
{
@Override
public void registerItem(RegistryEvent.Register<Item> event)
{
super.registerItem(event);
for (int i = 0; i < EnumActionResult.values().length; i++)
{
ModelLoader.setCustomModelResourceLocation(ItemTest.instance, i, new ModelResourceLocation(new ResourceLocation(MODID, "test_item"), "inventory"));
}
}
}
@SubscribeEvent
public static void registerItem(RegistryEvent.Register<Item> event)
{
if (ENABLE)
{
proxy.registerItem(event);
}
}
public static class ItemTest extends Item
{
static Item instance;
public ItemTest()
{
setRegistryName(MODID, "test_item");
setHasSubtypes(true);
}
@Nonnull
@Override
public EnumActionResult onItemUseFirst(EntityPlayer player, World world, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ, EnumHand hand)
{
ItemStack stack = player.getHeldItem(hand);
EnumActionResult ret = EnumActionResult.values()[stack.getMetadata()];
player.sendMessage(new TextComponentString("Called onItemUseFirst in thread " + Thread.currentThread().getName() + ", returns " + ret + " in hand " + hand.name()));
return ret;
}
@Override
public void getSubItems(CreativeTabs tab, NonNullList<ItemStack> subItems)
{
if (isInCreativeTab(tab))
{
for (int i = 0; i < EnumActionResult.values().length; i++)
{
subItems.add(new ItemStack(this, 1, i));
}
}
}
@Override
public String getItemStackDisplayName(ItemStack stack)
{
return "OnItemUseFirst Returns: " + EnumActionResult.values()[stack.getMetadata()];
}
}
}*/

View File

@ -1,143 +0,0 @@
/*
* Minecraft Forge
* Copyright (c) 2016-2019.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation version 2.1
* of the License.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
/*
package net.minecraftforge.debug.item;
import net.minecraft.client.renderer.model.ModelBakery;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemFood;
import net.minecraft.item.ItemStack;
import net.minecraft.potion.Potion;
import net.minecraft.potion.PotionEffect;
import net.minecraft.potion.PotionType;
import net.minecraft.world.World;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.client.event.ModelRegistryEvent;
import net.minecraftforge.event.RegistryEvent;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.registry.GameRegistry.ObjectHolder;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
*/
/**
* Usage (use survival so you can eat food):
* 1. Drink curable_potion from Brewing creative tab
* 2. Relog to test that changes to curative items persist, then eat the "medicine" item to cure the effect
* 3. Drink incurable_potion from Brewing creative tab
* 4. Relog to test that changes to curative items persist, then try drinking milk and eating medicine: they should have no effect
*//*
//@Mod(modid = PotionCurabilityTest.MODID, name = "Potion Curative Item Debug", version = "1.0", acceptableRemoteVersions = "*")
public class PotionCurabilityTest
{
public static final boolean ENABLED = false;
public static final String MODID = "potion_curative_item_debug";
@ObjectHolder("medicine")
public static final Item MEDICINE = null;
private static Potion INCURABLE_POTION;
//@Mod.EventBusSubscriber(modid = MODID)
public static class Registration
{
@SubscribeEvent
public static void registerItems(RegistryEvent.Register<Item> event)
{
if (!ENABLED) return;
event.getRegistry().register(new Medicine().setRegistryName(MODID, "medicine"));
}
@net.minecraftforge.eventbus.api.SubscribeEvent
public static void registerPotions(RegistryEvent.Register<Potion> event)
{
if (!ENABLED) return;
INCURABLE_POTION = new IncurablePotion().setRegistryName(MODID, "incurable_potion");
event.getRegistry().register(INCURABLE_POTION);
}
@SubscribeEvent
public static void registerPotionTypes(RegistryEvent.Register<PotionType> event)
{
if (!ENABLED) return;
// Register PotionType that can be cured with medicine
PotionEffect curable = new PotionEffect(INCURABLE_POTION, 1200);
curable.setCurativeItems(Collections.singletonList(new ItemStack(MEDICINE)));
event.getRegistry().register(new PotionType(curable).setRegistryName(MODID, "curable_potion_type"));
// Register PotionType that can't be cured
event.getRegistry().register(new PotionType(new PotionEffect(INCURABLE_POTION, 1200)).setRegistryName(MODID, "incurable_potion_type"));
}
}
//@Mod.EventBusSubscriber(value = Side.CLIENT, modid = MODID)
public static class ClientEventHandler
{
@SubscribeEvent
public static void registerModels(ModelRegistryEvent event)
{
if (!ENABLED) return;
ModelBakery.registerItemVariants(MEDICINE);
}
}
private static class IncurablePotion extends Potion
{
protected IncurablePotion()
{
super(false, 0x94A061);
setPotionName("incurable_potion");
setIconIndex(6, 0);
}
@Override
public List<ItemStack> getCurativeItems()
{
// By default, no PotionEffect of this Potion can be cured by anything
return new ArrayList<ItemStack>();
}
}
private static class Medicine extends ItemFood
{
public Medicine()
{
super(2, 1, false);
setUnlocalizedName("medicine");
setAlwaysEdible();
}
@Override
protected void onFoodEaten(ItemStack stack, World worldIn, EntityPlayer player)
{
if (!worldIn.isRemote)
{
player.curePotionEffects(stack);
}
}
}
}
*/

View File

@ -1,59 +0,0 @@
/*
* Minecraft Forge
* Copyright (c) 2016-2019.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation version 2.1
* of the License.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
/*
package net.minecraftforge.debug.item;
import net.minecraft.potion.Potion;
import net.minecraft.potion.PotionEffect;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.event.FMLPreInitializationEvent;
import net.minecraftforge.fml.common.registry.ForgeRegistries;
//@Mod(modid = PotionShouldRenderTest.modID, name = "No Potion Effect Render Test", version = "0.0.0", acceptableRemoteVersions = "*")
public class PotionShouldRenderTest
{
public static final String modID = "nopotioneffect";
@Mod.EventHandler
public void preInit(FMLPreInitializationEvent event)
{
TestPotion INSTANCE = (TestPotion)new TestPotion(new ResourceLocation(modID, "test_potion"), false, 0xff00ff).setRegistryName(new ResourceLocation(modID, "test_potion"));
ForgeRegistries.POTIONS.register(INSTANCE);
}
public static class TestPotion extends Potion
{
public TestPotion(ResourceLocation location, boolean badEffect, int potionColor)
{
super(badEffect, potionColor);
}
@Override
public boolean shouldRender(PotionEffect effect)
{
return false;
}
}
}
*/

View File

@ -1,108 +0,0 @@
/*
* Minecraft Forge
* Copyright (c) 2016-2019.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation version 2.1
* of the License.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
/*
package net.minecraftforge.debug.item;
import com.google.common.collect.Multimap;
import net.minecraft.client.renderer.model.ModelResourceLocation;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.SharedMonsterAttributes;
import net.minecraft.entity.ai.attributes.AttributeModifier;
import net.minecraft.inventory.EntityEquipmentSlot;
import net.minecraft.item.Item;
import net.minecraft.item.ItemShield;
import net.minecraft.item.ItemStack;
import net.minecraft.item.ItemSword;
import net.minecraft.util.text.translation.I18n;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.client.event.ModelRegistryEvent;
import net.minecraftforge.client.model.ModelLoader;
import net.minecraftforge.event.RegistryEvent;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.Mod.EventBusSubscriber;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.registry.GameRegistry.ObjectHolder;
import net.minecraftforge.api.distmarker.Dist;
@ObjectHolder("shield_test")
//@EventBusSubscriber
//@Mod(modid = "shield_test", name = "Shield Test", version = "0.0.0", acceptableRemoteVersions = "*")
public class ShieldTest
{
public static final ItemShield DIAMOND_SHIELD = null;
public static final ItemSword HEAVY_DIAMOND_SWORD = null;
@SubscribeEvent
public static void registerItems(RegistryEvent.Register<Item> event)
{
class ItemCustomShield extends ItemShield
{
@Override
public String getItemStackDisplayName(ItemStack stack)
{
return I18n.translateToLocal(this.getUnlocalizedNameInefficiently(stack) + ".name").trim();
}
@Override
public boolean isShield(ItemStack stack, EntityLivingBase entity)
{
return true;
}
}
class ItemHeavyDiamondSword extends ItemSword
{
public ItemHeavyDiamondSword()
{
super(ToolMaterial.DIAMOND);
}
@Override
public Multimap<String, AttributeModifier> getItemAttributeModifiers(EntityEquipmentSlot slot)
{
Multimap<String, AttributeModifier> multimap = super.getItemAttributeModifiers(slot);
if(slot == EntityEquipmentSlot.MAINHAND)
{
multimap.put(SharedMonsterAttributes.ATTACK_DAMAGE.getName(), new AttributeModifier(ATTACK_DAMAGE_MODIFIER, "Weapon modifier", 12.0F, 0));
multimap.put(SharedMonsterAttributes.ATTACK_SPEED.getName(), new AttributeModifier(ATTACK_SPEED_MODIFIER, "Weapon modifier", -5D, 0));
}
return multimap;
}
@Override
public boolean canDisableShield(ItemStack stack, ItemStack shield, EntityLivingBase entity, EntityLivingBase attacker)
{
return shield.getItem() != DIAMOND_SHIELD;
}
}
event.getRegistry().register(new ItemCustomShield().setMaxDamage(2098).setUnlocalizedName("diamond_shield").setRegistryName("diamond_shield"));
event.getRegistry().register(new ItemHeavyDiamondSword().setUnlocalizedName("heavy_diamond_sword").setRegistryName("heavy_diamond_sword"));
}
@OnlyIn(Dist.CLIENT)
@SubscribeEvent
public static void registerModels(ModelRegistryEvent event)
{
ModelLoader.setCustomModelResourceLocation(DIAMOND_SHIELD, 0, new ModelResourceLocation("shield_test:diamond_shield", "inventory"));
ModelLoader.setCustomModelResourceLocation(HEAVY_DIAMOND_SWORD, 0, new ModelResourceLocation("minecraft:diamond_sword", "inventory"));
}
}*/

View File

@ -1,65 +0,0 @@
/*
* Minecraft Forge
* Copyright (c) 2016-2019.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation version 2.1
* of the License.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
/*
package net.minecraftforge.debug.misc;
import net.minecraftforge.common.BiomeManager.BiomeType;
import net.minecraftforge.common.EnumPlantType;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.DeferredWorkQueue;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
import net.minecraftforge.fml.javafmlmod.FMLModLoadingContext;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
//@Mod("enumplanttypetest")
public class EnumPlantTypeTest
{
private static final Logger LOGGER = LogManager.getLogger();
public EnumPlantTypeTest()
{
FMLModLoadingContext.get().getModEventBus().addListener(this::setup);
}
@SubscribeEvent
public void setup(final FMLCommonSetupEvent event)
{
DeferredWorkQueue.runLater(() ->
{
int index = BiomeType.values().length;
BiomeType biomeType = BiomeType.create("FAKE");
if (biomeType == null || !biomeType.name().equals("FAKE") || biomeType.ordinal() != index)
{
LOGGER.warn("RuntimeEnumExtender is working incorrectly for BiomeType!");
}
EnumPlantType plantType = EnumPlantType.create("FAKE");
if (plantType == null || !plantType.name().equals("FAKE") || plantType != EnumPlantType.create("FAKE"))
{
LOGGER.warn("RuntimeEnumExtender is working incorrectly for EnumPlantType!");
}
});
}
}
*/

View File

@ -1,326 +0,0 @@
/*
* Minecraft Forge
* Copyright (c) 2016-2019.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation version 2.1
* of the License.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
/*
package net.minecraftforge.debug.mod;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTBase;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.Vec3d;
import net.minecraft.util.text.TextComponentString;
import net.minecraft.util.text.TextFormatting;
import net.minecraft.village.Village;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.common.capabilities.Capability;
import net.minecraftforge.common.capabilities.Capability.IStorage;
import net.minecraftforge.common.capabilities.CapabilityInject;
import net.minecraftforge.common.capabilities.CapabilityManager;
import net.minecraftforge.common.capabilities.ICapabilitySerializable;
import net.minecraftforge.event.AttachCapabilitiesEvent;
import net.minecraftforge.event.entity.player.PlayerInteractEvent;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.event.FMLPreInitializationEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.event.TickEvent;
import org.apache.logging.log4j.Logger;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.util.List;
//@Mod(modid = "forge.testcapmod", name = "Forge TestCapMod", version = "1.0", acceptableRemoteVersions = "*")
public class CapabilityTest
{
// A Holder/Marker for if this capability is installed.
// MUST be Static final doesn't matter but is suggested to prevent
// you from overriding it elsewhere.
// As Annotations and generic's are erased/unload at runtime this
// does NOT create a hard dependency on the class.
@CapabilityInject(IExampleCapability.class)
private static final Capability<IExampleCapability> TEST_CAP = null;
static final boolean ENABLED = false;
private static Logger logger;
@Mod.EventHandler
public void preinit(FMLPreInitializationEvent evt)
{
logger = evt.getModLog();
// If you are a API, provide register your capability ASAP.
// You MUST supply a default save handler and a default implementation
// If you are a CONSUMER of the capability DO NOT register it. Only APIs should.
CapabilityManager.INSTANCE.register(IExampleCapability.class, new Storage(), DefaultImpl::new);
MinecraftForge.EVENT_BUS.register(this);
}
@SubscribeEvent
public void onInteract(PlayerInteractEvent.LeftClickBlock event)
{
if (!ENABLED || event.getItemStack().getItem() != Items.STICK)
{
return;
}
// This is just a example of how to interact with the TE, note the strong type binding that getCapability has
TileEntity te = event.getWorld().getTileEntity(event.getPos());
if (te != null && te.hasCapability(TEST_CAP, event.getFace()))
{
event.setCanceled(true);
IExampleCapability inv = te.getCapability(TEST_CAP, event.getFace());
logger.info("Hi I'm a {}", inv.getOwnerType());
}
if (event.getWorld().getBlockState(event.getPos()).getBlock() == Blocks.DIRT && event.getItemStack().hasCapability(TEST_CAP, null))
{
IExampleCapability cap = event.getItemStack().getCapability(TEST_CAP, null);
event.getEntityPlayer().sendMessage(new TextComponentString((cap.getVal() ? TextFormatting.GREEN : TextFormatting.RED) + "" + TextFormatting.ITALIC + "TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST"));
event.setCanceled(true);
}
}
@SubscribeEvent
public void onInteractItem(PlayerInteractEvent.RightClickItem event)
{
if (!ENABLED || !event.getEntityPlayer().isSneaking())
{
return;
}
if (event.getItemStack().hasCapability(TEST_CAP, null))
{
IExampleCapability cap = event.getItemStack().getCapability(TEST_CAP, null);
cap.toggleVal();
logger.info("Test value is now: {}", cap.getVal() ? "TRUE" : "FALSE");
}
}
// Example of having this annotation on a method, this will be called when the capability is present.
// You could do something like register event handlers to attach these capabilities to objects, or
// setup your factory, who knows. Just figured i'd give you the power.
@CapabilityInject(IExampleCapability.class)
private static void capRegistered(Capability<IExampleCapability> cap)
{
logger.info("IExampleCapability was registered wheeeeee!");
}
// Having the Provider implement the cap is not recommended as this creates a hard dep on the cap interface.
// And does not allow for sidedness.
// But as this is a example and we do not care about that here we go.
class Provider<V> implements ICapabilitySerializable<NBTTagCompound>, IExampleCapability
{
private V obj;
private boolean value;
Provider(V obj)
{
this.obj = obj;
}
@Override
public boolean hasCapability(@Nonnull Capability<?> capability, @Nullable EnumFacing facing)
{
return TEST_CAP != null && capability == TEST_CAP;
}
@Override
@Nullable
public <T> T getCapability(@Nonnull Capability<T> capability, @Nullable EnumFacing facing)
{
if (TEST_CAP != null && capability == TEST_CAP)
{
return TEST_CAP.cast(this);
}
return null;
}
@Override
public NBTTagCompound serializeNBT()
{
NBTTagCompound tag = new NBTTagCompound();
tag.setBoolean("CapTestVal", this.value);
return tag;
}
@Override
public void deserializeNBT(NBTTagCompound tag)
{
this.value = tag.getBoolean("CapTestVal");
}
@Override
public String getOwnerType()
{
return obj.getClass().getName();
}
@Override
public boolean getVal()
{
return this.value;
}
@Override
public void toggleVal()
{
this.value = !this.value;
}
}
// An example of how to attach a capability to an arbitrary Tile entity.
// Note: Doing this IS NOT recommended for normal implementations.
// If you control the TE it is HIGHLY recommend that you implement a fast
// version of the has/getCapability functions yourself. So you have control
// over everything yours being called first.
@SubscribeEvent
public void onTELoad(AttachCapabilitiesEvent<TileEntity> event)
{
//Attach it! The resource location MUST be unique it's recommended that you tag it with your modid and what the cap is.
event.addCapability(new ResourceLocation("forge.testcapmod:dummy_cap"), new Provider<TileEntity>(event.getObject()));
}
@SubscribeEvent
public void onItemLoad(AttachCapabilitiesEvent<ItemStack> event)
{
if (event.getObject().getItem() == Items.STICK)
{
event.addCapability(new ResourceLocation("forge.testcapmod:dummy_cap"), new Provider<ItemStack>(event.getObject()));
}
}
@SuppressWarnings("rawtypes")
@SubscribeEvent
public void attachEvent(AttachCapabilitiesEvent event) //Test Raw type gets everything still.
{
System.currentTimeMillis();
}
@SubscribeEvent
public void attachTileEntity(AttachCapabilitiesEvent<TileEntity> event)
{
if (!(event.getObject() instanceof TileEntity))
{
throw new IllegalArgumentException("Generic event handler failed! Expected Tile Entity got " + event.getObject());
}
}
@SubscribeEvent
public void attachVillage(AttachCapabilitiesEvent<Village> event)
{
System.out.println(event.getObject());
event.addCapability(new ResourceLocation("forge.testcapmod:dummy_cap"), new Provider(event.getObject()));
}
//Detects if a player has entered the radius of a village
@SubscribeEvent
public void tick(TickEvent.WorldTickEvent event)
{
if (ENABLED && !event.world.isRemote)
{
List<EntityPlayer> players = event.world.playerEntities;
int i = 0;
for (Village village : event.world.villageCollection.getVillageList())
{
if (village.hasCapability(TEST_CAP, null))
{
boolean playerInRadius = false;
for (EntityPlayer player : players)
{
if (new Vec3d(player.posX, 0, player.posZ).squareDistanceTo(new Vec3d(village.getCenter().getX(), 0, village.getCenter().getZ())) <= village.getVillageRadius() * village.getVillageRadius())
{
playerInRadius = playerInRadius || true;
}
}
//If the test cap is true but no players are in radius
if (village.getCapability(TEST_CAP, null).getVal() && !playerInRadius)
{
village.getCapability(TEST_CAP, null).toggleVal();
for (EntityPlayer player : players)
player.sendMessage(new TextComponentString(TextFormatting.RED + "All Players Have Exited Village " + i));
}
//If the test cap is false but there are players in radius
else if (!village.getCapability(TEST_CAP, null).getVal() && playerInRadius)
{
village.getCapability(TEST_CAP, null).toggleVal();
for (EntityPlayer player : players)
player.sendMessage(new TextComponentString(TextFormatting.GREEN + "Some Players Have Entered Village " + i));
}
}
i++;
}
}
}
// Capabilities SHOULD be interfaces, NOT concrete classes, this allows for
// the most flexibility for the implementors.
public interface IExampleCapability
{
String getOwnerType();
boolean getVal();
void toggleVal();
}
// Storage implementations are required, tho there is some flexibility here.
// If you are the API provider you can also say that in order to use the default storage
// the consumer MUST use the default impl, to allow you to access innards.
// This is just a contract you will have to stipulate in the documentation of your cap.
public static class Storage implements IStorage<IExampleCapability>
{
@Override
public NBTBase writeNBT(Capability<IExampleCapability> capability, IExampleCapability instance, EnumFacing side)
{
return null;
}
@Override
public void readNBT(Capability<IExampleCapability> capability, IExampleCapability instance, EnumFacing side, NBTBase nbt)
{
}
}
// You MUST also supply a default implementation.
// This is to make life easier on consumers.
public static class DefaultImpl implements IExampleCapability
{
@Override
public String getOwnerType()
{
return "Default Implementation!";
}
public boolean getVal()
{
return false;
}
@Override
public void toggleVal()
{
}
}
}
*/

View File

@ -1,113 +0,0 @@
/*
* Minecraft Forge
* Copyright (c) 2016-2019.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation version 2.1
* of the License.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
/*
package net.minecraftforge.debug.mod;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.gui.GuiErrorScreen;
import net.minecraft.item.Item;
import net.minecraftforge.client.event.ModelBakeEvent;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.RegistryEvent;
import net.minecraftforge.fml.client.gui.CustomModLoadingErrorDisplayException;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.event.FMLInitializationEvent;
import net.minecraftforge.fml.event.FMLLoadCompleteEvent;
import net.minecraftforge.fml.event.FMLPreInitializationEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
//@Mod(modid = "clientexceptiontest", version = "1.0", name = "Client Exception Test", clientSideOnly = true)
public class ClientLoadingExceptionTest
{
// Disabled so other test mods can still work.
public static boolean ENABLE_PREINIT = false;
public static boolean ENABLE_INIT = false;
public static boolean ENABLE_LOAD_COMPLETE = false;
public static boolean ENABLE_SERVER_STARTED = false;
@Mod.EventHandler
public void onPreInit(FMLPreInitializationEvent e)
{
if (ENABLE_PREINIT)
{
MinecraftForge.EVENT_BUS.register(this);
throwException("Thrown in Pre-Init");
}
}
@SubscribeEvent
public void registerItems(RegistryEvent<Item> itemRegistryEvent)
{
throw new RuntimeException("This should not be called because the mod threw an exception earlier in Pre-Init and is in a broken state.");
}
@SubscribeEvent
public void onModelBake(ModelBakeEvent e)
{
throw new RuntimeException("This should not be called because the mod threw an exception earlier in Pre-Init and is in a broken state.");
}
@Mod.EventHandler
public void onInit(FMLInitializationEvent e)
{
if (ENABLE_INIT)
{
throwException("Thrown in Init");
}
}
@Mod.EventHandler
public void onLoadComplete(FMLLoadCompleteEvent e)
{
if (ENABLE_LOAD_COMPLETE)
{
throwException("Thrown in load complete");
}
}
@Mod.EventHandler
public void onServerStarted(FMLServerStartedEvent e)
{
if (ENABLE_SERVER_STARTED)
{
throw new RuntimeException("Server thread exception - should stop client");
}
}
private void throwException(String runtimeMessage)
{
throw new CustomModLoadingErrorDisplayException("Custom Test Exception", new RuntimeException(runtimeMessage))
{
@Override
public void initGui(GuiErrorScreen parent, FontRenderer fontRenderer) {}
@Override
public void drawScreen(GuiErrorScreen parent, FontRenderer fontRenderer, int mouseRelX, int mouseRelY, float tickTime)
{
parent.drawCenteredString(parent.mc.fontRenderer, "Custom Test Exception", parent.width / 2, 90, 16777215);
parent.drawCenteredString(parent.mc.fontRenderer, runtimeMessage, parent.width / 2, 110, 16777215);
}
};
}
}
*/

View File

@ -1,232 +0,0 @@
/*
* Minecraft Forge
* Copyright (c) 2016-2019.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation version 2.1
* of the License.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
/*
package net.minecraftforge.debug.mod;
import com.google.common.collect.Maps;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.common.config.Config;
import net.minecraftforge.common.config.Config.Comment;
import net.minecraftforge.common.config.Config.LangKey;
import net.minecraftforge.common.config.Config.Name;
import net.minecraftforge.common.config.Config.RangeDouble;
import net.minecraftforge.common.config.Config.RangeInt;
import net.minecraftforge.common.config.Config.RequiresMcRestart;
import net.minecraftforge.common.config.Config.Type;
import net.minecraftforge.common.config.ConfigManager;
import net.minecraftforge.fml.client.event.ConfigChangedEvent.OnConfigChangedEvent;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.event.FMLInitializationEvent;
import net.minecraftforge.fml.event.FMLPreInitializationEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import org.apache.logging.log4j.Logger;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
//@Mod(modid = ConfigAnnotationTest.MODID, name = "ConfigTest", version = "1.0", acceptableRemoteVersions = "*")
public class ConfigAnnotationTest
{
public static final String MODID = "config_test";
private static Logger logger;
@Mod.EventHandler
public void preInit(FMLPreInitializationEvent event)
{
logger = event.getModLog();
MinecraftForge.EVENT_BUS.register(this);
}
@Mod.EventHandler
public void init(FMLInitializationEvent event)
{
logger.info("Starting config modification test.");
logger.debug("Starting simple variable change test.");
logger.debug("Old: {}", CONFIG_TYPES.bool);
CONFIG_TYPES.bool = !CONFIG_TYPES.bool;
logger.debug("New: {}", CONFIG_TYPES.bool);
ConfigManager.sync(MODID, Type.INSTANCE);
logger.debug("After sync: {}", CONFIG_TYPES.bool);
logger.debug("Starting map key addition test.");
logger.debug("Old map keys: {}", Arrays.deepToString(ROOT_CONFIG_TEST.mapTest.keySet().toArray()));
String key = "" + System.currentTimeMillis();
logger.debug("Adding key: {}", key);
ROOT_CONFIG_TEST.mapTest.put(key, Math.PI);
ConfigManager.sync(MODID, Type.INSTANCE);
logger.debug("Keys after sync: {}", Arrays.deepToString(ROOT_CONFIG_TEST.mapTest.keySet().toArray()));
logger.debug("Synced. Check config gui to verify the key was added properly");
}
@SubscribeEvent
public void onConfigChangedEvent(OnConfigChangedEvent event)
{
if (event.getModID().equals(MODID))
{
ConfigManager.sync(MODID, Type.INSTANCE);
}
}
@Config(modid = MODID, type = Type.INSTANCE)
public static class ROOT_CONFIG_TEST {
public static HashMap<String, Double> mapTest = new HashMap<>();
static {
mapTest.put("foobar", 2.0);
mapTest.put("foobaz", 100.5);
mapTest.put("barbaz", Double.MAX_VALUE);
}
}
@LangKey("config_test.config.types")
@Config(modid = MODID, type = Type.INSTANCE, name = MODID + "_types", category = "types")
public static class CONFIG_TYPES
{
public static boolean bool = false;
public static boolean[] boolA = {false, true};
public static Boolean Bool = false;
public static Boolean[] BoolA = {false, true};
public static float flt = 1.0f;
public static float[] fltA = {1.0f, 2.0f};
public static Float Flt = 1.0f;
public static Float[] FltA = {1.0f, 2.0f};
public static double dbl = 1.0d;
public static double[] dblA = {1.0d, 2.0d};
public static Double Dbl = 1.0D;
public static Double[] DblA = {1.0D, 2.0D};
public static byte byt = 1;
public static byte[] bytA = {1, 2};
public static Byte Byt = 1;
public static Byte[] BytA = {1, 2};
public static char chr = 'a';
public static char[] chrA = {'a', 'b'};
public static Character Chr = 'A';
public static Character[] ChrA = {'A', 'B'};
public static short srt = 1;
public static short[] srtA = {1, 2};
public static Short Srt = 1;
public static Short[] SrtA = {1, 2};
public static int int_ = 1;
public static int[] intA = {1, 2};
public static Integer Int = 1;
public static Integer[] IntA = {1, 2};
public static String Str = "STRING!";
public static String[] StrA = {"STR", "ING!"};
public static TEST enu = TEST.BIG;
public static NestedType Inner = new NestedType();
public enum TEST { BIG, BAD, WOLF; }
public static class NestedType
{
public String HeyLook = "I'm Inside!";
}
}
@LangKey("config_test.config.annotations")
@Config(modid = MODID, category = "annotations")
public static class CONFIG_ANNOTATIONS
{
@RangeDouble(min = -10.5, max = 100.5)
public static double DoubleRange = 10.0;
@RangeInt(min = -10, max = 100)
public static double IntRange = 10;
@LangKey("this.is.not.a.good.key")
@Comment({"This is a really long", "Multi-line comment"})
public static String Comments = "Hi Tv!";
@Comment("Category Comment Test")
public static NestedType Inner = new NestedType();
public static class NestedType
{
public String HeyLook = "Go in!";
}
}
@LangKey("config_test.config.subcats")
@Config(modid = MODID, name = MODID + "_subcats", category = "subcats")
public static class CONFIG_SUBCATS
{
//public static String THIS_WILL_ERROR = "DUH";
@Name("test_a")
public static SubCat sub1 = new SubCat("Hello");
@Name("test_b")
public static SubCat sub2 = new SubCat("Goodbye");
@Name("test_c")
public static SubCat2 sub3 = new SubCat2("Hi");
public static class SubCat
{
@Name("i_say")
public String value;
public SubCat(String value)
{
this.value = value;
}
}
public static class SubCat2
{
@Name("child_cat")
public SubCat child;
public SubCat2(String value)
{
this.child = new SubCat(value);
}
}
}
@LangKey("config_test.config.maps")
@Config(modid = MODID, name = MODID + "_map", category = "maps")
public static class CONFIG_MAP
{
@Name("map")
@Comment("This comment belongs to the \"map\" category, not the \"general\" category")
@RequiresMcRestart
public static Map<String, Integer[]> theMap;
@Name("regex(test]")
public static Map<String, String> regexText = new HashMap<>();
static
{
theMap = Maps.newHashMap();
for (int i = 0; i < 7; i++)
{
Integer[] array = new Integer[6];
for (int x = 0; x < array.length; x++)
{
array[x] = i + x;
}
theMap.put("" + i, array);
regexText.put("" + i, "" + i);
}
}
}
}
*/

View File

@ -1,157 +0,0 @@
/*
* Minecraft Forge
* Copyright (c) 2016-2019.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation version 2.1
* of the License.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
/*
package net.minecraftforge.debug.mod;
import net.minecraft.block.Block;
import net.minecraft.potion.Potion;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.SoundEvent;
import net.minecraftforge.event.RegistryEvent;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.event.FMLInitializationEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.registry.GameRegistry;
import net.minecraftforge.registries.IForgeRegistryEntry;
import net.minecraftforge.registries.RegistryBuilder;
//@Mod(modid = ObjectHolderAnnotationTest.MODID, name = "ObjectHolderTests", version = "1.0", acceptableRemoteVersions = "*")
public class ObjectHolderAnnotationTest
{
public static final String MODID = "objectholdertest";
@Mod.EventHandler
public void init(FMLInitializationEvent event)
{
//verifies @ObjectHolder with custom id
assert VanillaObjectHolder.uiButtonClick != null;
//verifies modded items work
assert ForgeObjectHolder.forge_potion != null;
//verifies minecraft:air is now resolvable
assert VanillaObjectHolder.air != null;
//verifies unexpected name should not have defaulted to AIR.
assert VanillaObjectHolder.nonExistentBlock == null;
//verifies custom registries
assert CustomRegistryObjectHolder.custom_entry != null;
//verifies interfaces are supported
assert CustomRegistryObjectHolder.custom_entry_by_interface != null;
}
protected static class PotionForge extends Potion
{
protected PotionForge(ResourceLocation location, boolean badEffect, int potionColor)
{
super(badEffect, potionColor);
setPotionName("potion." + location.getResourcePath());
setRegistryName(location);
}
}
//@Mod.EventBusSubscriber(modid = MODID)
public static class Registration
{
@net.minecraftforge.eventbus.api.SubscribeEvent
public static void newRegistry(RegistryEvent.NewRegistry event)
{
new RegistryBuilder<ICustomRegistryEntry>()
.setType(ICustomRegistryEntry.class)
.setName(new ResourceLocation("object_holder_test_custom_registry"))
.setIDRange(0, 255)
.create();
}
@net.minecraftforge.eventbus.api.SubscribeEvent
public static void registerPotions(RegistryEvent.Register<Potion> event)
{
event.getRegistry().register(
new ObjectHolderAnnotationTest.PotionForge(new ResourceLocation(ObjectHolderAnnotationTest.MODID, "forge_potion"), false, 0xff00ff) // test automatic id distribution
);
}
@SubscribeEvent
public static void registerInterfaceRegistryForge(RegistryEvent.Register<ICustomRegistryEntry> event)
{
event.getRegistry().register(
new CustomRegistryEntry().setRegistryName(new ResourceLocation(MODID, "custom_entry_by_interface"))
);
event.getRegistry().register(
new CustomRegistryEntry().setRegistryName(new ResourceLocation(MODID, "custom_entry"))
);
}
}
interface ICustomRegistryEntry extends IForgeRegistryEntry<ICustomRegistryEntry>{}
static class CustomRegistryEntry implements ICustomRegistryEntry
{
private ResourceLocation name;
@Override
public ICustomRegistryEntry setRegistryName(ResourceLocation name)
{
this.name = name;
return this;
}
@Override
public ResourceLocation getRegistryName()
{
return name;
}
@Override
public Class<ICustomRegistryEntry> getRegistryType()
{
return ICustomRegistryEntry.class;
}
}
@GameRegistry.ObjectHolder("minecraft")
static class VanillaObjectHolder
{
//Tests importing vanilla objects that need the @ObjectHolder annotation to get a valid ResourceLocation
@GameRegistry.ObjectHolder("ui.button.click")
public static final SoundEvent uiButtonClick = null;
public static final Block air = null;
public static final Block nonExistentBlock = null;
}
@GameRegistry.ObjectHolder(ObjectHolderAnnotationTest.MODID)
static class ForgeObjectHolder
{
//Tests using subclasses for injections
public static final ObjectHolderAnnotationTest.PotionForge forge_potion = null;
}
@GameRegistry.ObjectHolder(ObjectHolderAnnotationTest.MODID)
static class CustomRegistryObjectHolder
{
//Tests whether custom registries can be used
public static final ICustomRegistryEntry custom_entry = null;
//Tests whether interfaces can be used
public static final ICustomRegistryEntry custom_entry_by_interface = null;
}
}
*/

View File

@ -1,200 +0,0 @@
/*
* Minecraft Forge
* Copyright (c) 2016-2019.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation version 2.1
* of the License.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
/*
package net.minecraftforge.debug.mod;
import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState;
import net.minecraft.command.CommandBase;
import net.minecraft.command.CommandException;
import net.minecraft.command.ICommandSender;
import net.minecraft.command.WrongUsageException;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.server.MinecraftServer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.ChunkPos;
import net.minecraft.util.text.TextComponentString;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.event.FMLInitializationEvent;
import net.minecraftforge.fml.event.FMLServerStartingEvent;
import net.minecraftforge.server.permission.DefaultPermissionLevel;
import net.minecraftforge.server.permission.PermissionAPI;
import net.minecraftforge.server.permission.context.BlockPosContext;
import net.minecraftforge.server.permission.context.ContextKey;
//@Mod(modid = PermissionTest.MOD_ID, name = "PermissionTest", version = "1.0.0", acceptableRemoteVersions = "*")
public class PermissionTest
{
public static final String MOD_ID = "permission_test";
@Mod.Instance(PermissionTest.MOD_ID)
public static PermissionTest inst;
@Mod.EventHandler
public void onInit(FMLInitializationEvent event)
{
Permissions.init();
}
@Mod.EventHandler
public void onServerStarted(FMLServerStartingEvent event)
{
event.registerServerCommand(new CommandPermissionTest());
}
public static class Permissions
{
public static final String CLAIM_CHUNK = "testmod.chunk.claim";
public static final String UNCLAIM_CHUNK = "testmod.chunk.unclaim";
public static final String SET_BLOCK = "testmod.block.set";
public static final String READ_TILE = "testmod.tileentity.read";
public static void init()
{
PermissionAPI.registerNode(CLAIM_CHUNK, DefaultPermissionLevel.ALL, "Node for claiming chunks");
PermissionAPI.registerNode(UNCLAIM_CHUNK, DefaultPermissionLevel.ALL, "Node for unclaiming chunks");
PermissionAPI.registerNode(SET_BLOCK, DefaultPermissionLevel.OP, "Node for setting blocks with a command");
PermissionAPI.registerNode(READ_TILE, DefaultPermissionLevel.NONE, "Node for reading and printing TileEntity data");
}
}
public static class ContextKeys
{
public static final ContextKey<TileEntity> TILE_ENTITY = ContextKey.create("tile_entity", TileEntity.class);
}
public static class CommandPermissionTest extends CommandBase
{
@Override
public String getName()
{
return "permission_test";
}
@Override
public String getUsage(ICommandSender sender)
{
return "commands.permission_test.usage";
}
@Override
public boolean checkPermission(MinecraftServer server, ICommandSender sender)
{
return true;
}
@Override
public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException
{
EntityPlayerMP player = getCommandSenderAsPlayer(sender);
if (args.length < 1)
{
sender.sendMessage(new TextComponentString("claim, unclaim, setblock, read_tile"));
return;
}
//Example using BlockPosContext with ChunkPos and permission available to players by default
boolean b = args[0].equals("claim");
if (b || args[0].equals("unclaim"))
{
ChunkPos chunkPos = new ChunkPos(parseInt(args[1]), parseInt(args[2]));
if (PermissionAPI.hasPermission(player.getGameProfile(), b ? Permissions.CLAIM_CHUNK : Permissions.UNCLAIM_CHUNK, new BlockPosContext(player, chunkPos)))
{
if (b)
{
//claim chunk
sender.sendMessage(new TextComponentString("Chunk claimed!"));
}
else
{
//unclaim chunk
sender.sendMessage(new TextComponentString("Chunk unclaimed!"));
}
}
else
{
throw new CommandException("commands.generic.permission");
}
}
//Example using BlockPosContext and permission available to only OPs by default
else if (args[0].equals("setblock"))
{
if (args.length < 5)
{
throw new WrongUsageException("commands.setblock.usage");
}
BlockPos blockpos = parseBlockPos(sender, args, 1, false);
Block block = CommandBase.getBlockByText(sender, args[4]);
int i = 0;
if (args.length >= 6)
{
i = parseInt(args[5], 0, 15);
}
if (!player.world.isBlockLoaded(blockpos))
{
throw new CommandException("commands.setblock.outOfWorld");
}
else
{
IBlockState state = block.getStateFromMeta(i);
if (!PermissionAPI.hasPermission(player.getGameProfile(), Permissions.SET_BLOCK, new BlockPosContext(player, blockpos, state, null)))
{
throw new CommandException("commands.generic.permission");
}
else if (!player.world.setBlockState(blockpos, state, 2))
{
throw new CommandException("commands.setblock.noChange");
}
}
}
//Example using custom ContextKey and permission available to only OPs by default
else if (args[0].equals("read_tile"))
{
BlockPos blockpos = parseBlockPos(sender, args, 1, false);
TileEntity tileEntity = player.world.getTileEntity(blockpos);
if (PermissionAPI.hasPermission(player.getGameProfile(), Permissions.READ_TILE, new BlockPosContext(player, blockpos, null, null).set(ContextKeys.TILE_ENTITY, tileEntity)))
{
NBTTagCompound tag = tileEntity == null ? null : tileEntity.serializeNBT();
sender.sendMessage(new TextComponentString(String.valueOf(tag)));
}
else
{
throw new CommandException("commands.generic.permission");
}
}
else
{
throw new CommandException("commands.generic.permission");
}
}
}
}
*/

View File

@ -1,129 +0,0 @@
/*
* Minecraft Forge
* Copyright (c) 2016-2019.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation version 2.1
* of the License.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
/*
package net.minecraftforge.debug.mod;
import net.minecraft.block.Block;
import net.minecraft.block.SoundType;
import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.potion.Potion;
import net.minecraft.potion.PotionType;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumHand;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.text.TextComponentString;
import net.minecraft.world.World;
import net.minecraftforge.event.RegistryEvent;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.eventbus.api.SubscribeEvent;
//@Mod(modid = RegistryOverrideTest.MODID, name = "Registry override test mod", version = "1.0", acceptableRemoteVersions = "*")
//@Mod.EventBusSubscriber
public class RegistryOverrideTest
{
public static final String MODID = "registry_override_test";
static final boolean ENABLED = false;
@net.minecraftforge.eventbus.api.SubscribeEvent
public static void registerBlocks(RegistryEvent.Register<Block> event)
{
if (ENABLED)
{
event.getRegistry().register(new BlockReplacement());
}
}
@SubscribeEvent
public static void registerItems(RegistryEvent.Register<Item> event)
{
if (!ENABLED) return;
event.getRegistry().register(
new Item()
.setFull3D()
.setUnlocalizedName("stick")
.setCreativeTab(CreativeTabs.MATERIALS)
.setRegistryName("minecraft:stick")
);
}
@SubscribeEvent
public static void registerPotionTypes(RegistryEvent.Register<PotionType> event)
{
if (ENABLED)
{
event.getRegistry().register(new PotionType().setRegistryName("minecraft:awkward"));
}
}
@SubscribeEvent
public static void registerPotions(RegistryEvent.Register<Potion> event)
{
if (ENABLED)
{
event.getRegistry().register(new Potion(true, 0x00ffff)
{
{
setPotionName("effect.poison");
setIconIndex(6, 0);
setEffectiveness(0.25D);
}
}.setRegistryName("minecraft:poison"));
}
}
private static class BlockReplacement extends Block
{
AxisAlignedBB BB = FULL_BLOCK_AABB.contract(0.1, 0, 0.1);
private BlockReplacement()
{
super(Material.ROCK);
setRegistryName("minecraft", "bookshelf");
this.setHardness(1.5F);
this.setSoundType(SoundType.STONE).setUnlocalizedName("bookshelf");
this.setCreativeTab(CreativeTabs.BUILDING_BLOCKS);
}
@Override
public String toString()
{
return "BlockReplacement{" + this.getRegistryName() + "}";
}
@Override
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ)
{
if (hand == EnumHand.MAIN_HAND)
{
playerIn.sendMessage(new TextComponentString(worldIn.isRemote ? "Client" : "Server"));
}
return false;
}
}
}
*/

View File

@ -1,25 +0,0 @@
/*
* Minecraft Forge
* Copyright (c) 2016-2019.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation version 2.1
* of the License.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
@ParametersAreNonnullByDefault
@MethodsReturnNonnullByDefault
package net.minecraftforge.debug.mod;
import javax.annotation.ParametersAreNonnullByDefault;
import mcp.MethodsReturnNonnullByDefault;

View File

@ -1,89 +0,0 @@
/*
* Minecraft Forge
* Copyright (c) 2016-2019.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation version 2.1
* of the License.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
/*
package net.minecraftforge.debug.network;
import io.netty.buffer.ByteBuf;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.event.FMLPreInitializationEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.gameevent.PlayerEvent;
import net.minecraftforge.fml.common.network.NetworkRegistry;
import net.minecraftforge.fml.common.network.simpleimpl.IMessage;
import net.minecraftforge.fml.common.network.simpleimpl.SimpleNetworkWrapper;
//@Mod(modid = BigNetworkMessageTest.MOD_ID, name = "Big network message test mod", version = "1.0", acceptableRemoteVersions = "*")
//@Mod.EventBusSubscriber
public class BigNetworkMessageTest
{
static final boolean ENABLED = false;
static final String MOD_ID = "big_packet_test";
public static final SimpleNetworkWrapper INSTANCE = NetworkRegistry.INSTANCE.newSimpleChannel(MOD_ID);
@Mod.EventHandler
public void preInit(FMLPreInitializationEvent e)
{
if (ENABLED)
{
INSTANCE.registerMessage((msg, ctx) -> null, BigMessage.class, 0, Side.SERVER);
}
}
@SubscribeEvent
public static void onPlayerJoin(PlayerEvent.PlayerLoggedInEvent evt)
{
if (ENABLED)
{
INSTANCE.sendTo(new BigMessage(), (EntityPlayerMP) evt.player);
}
}
public static class BigMessage implements IMessage
{
private static final int BYTE_COUNT = 0x200000;// 2MB
@Override public void toBytes(ByteBuf buf)
{
// write consecutive bytes, overflowing back to zero as necessary
for (int i = 0; i < BYTE_COUNT; i++)
{
buf.writeByte(i & 0xFF);
}
}
@Override public void fromBytes(ByteBuf buf)
{
for (int i = 0; i < BYTE_COUNT; i++)
{
int read = buf.readUnsignedByte();
int expected = i & 0xFF;
if (read != expected)
{
throw new RuntimeException("Found incorrect byte at " + (i + 1) + " expected " + expected + " but found " + read);
}
}
}
}
}
*/

View File

@ -1,145 +0,0 @@
/*
* Minecraft Forge
* Copyright (c) 2016-2019.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation version 2.1
* of the License.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
/*
package net.minecraftforge.debug.network;
import io.netty.buffer.ByteBuf;
import net.minecraft.entity.item.EntityItemFrame;
import net.minecraft.init.Items;
import net.minecraftforge.event.entity.EntityJoinWorldEvent;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.event.FMLPreInitializationEvent;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.event.TickEvent;
import net.minecraftforge.fml.common.network.NetworkRegistry;
import net.minecraftforge.fml.common.network.simpleimpl.IMessage;
import net.minecraftforge.fml.common.network.simpleimpl.IMessageHandler;
import net.minecraftforge.fml.common.network.simpleimpl.MessageContext;
import net.minecraftforge.fml.common.network.simpleimpl.SimpleNetworkWrapper;
import net.minecraftforge.fml.relauncher.Side;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import java.util.Collections;
import java.util.Set;
import java.util.WeakHashMap;
//@Mod(modid = TrackingTargetTest.ID, name = "Tracking Target Test", acceptableRemoteVersions = "*")
//@Mod.EventBusSubscriber
public class TrackingTargetTest
{
public static final String ID = "trackingtargettest";
private static boolean ENABLED = false;
private static final SimpleNetworkWrapper NET = new SimpleNetworkWrapper(ID);
private static final Logger LOGGER = LogManager.getLogger(ID);
@Mod.EventHandler
public static void preinit(FMLPreInitializationEvent evt)
{
NET.registerMessage(TestMessageHandler.class, TestMessage.class, 0, Side.CLIENT);
NET.registerMessage(TestEntityMessageHandler.class, TestEntityMessage.class, 1, Side.CLIENT);
}
// Every 3 seconds, send a message to all players tracking overworld (500, 500).
// If you move sufficiently far away (i.e greater than the server render distance) from (500, 500), you should stop receiving the messages.
@SubscribeEvent
public static void tick(TickEvent.WorldTickEvent evt)
{
if (ENABLED && evt.side == Side.SERVER && evt.phase == TickEvent.Phase.END)
{
if (evt.world.getWorldTime() % 60 == 0)
{
NetworkRegistry.TargetPoint pt = new NetworkRegistry.TargetPoint(0, 500, 0, 500, -1);
NET.sendToAllTracking(new TestMessage(), pt);
}
}
}
public static class TestMessage implements IMessage
{
@Override
public void fromBytes(ByteBuf buf) {}
@Override
public void toBytes(ByteBuf buf) {}
}
public static class TestMessageHandler implements IMessageHandler<TestMessage, IMessage>
{
@Override
public IMessage onMessage(TestMessage message, MessageContext ctx)
{
LOGGER.info("Received tracking point test message");
return null;
}
}
// Every 3 seconds, send a message to all players tracking any item frame with a stick in it
// If you move sufficiently far away from the frame, you should stop receiving the messages.
private static final Set<EntityItemFrame> FRAMES = Collections.newSetFromMap(new WeakHashMap<>());
@SubscribeEvent
public static void frameJoin(EntityJoinWorldEvent evt)
{
if (ENABLED && !evt.getWorld().isRemote && evt.getEntity() instanceof EntityItemFrame)
{
FRAMES.add((EntityItemFrame) evt.getEntity());
}
}
@SubscribeEvent
public static void tickEntity(TickEvent.WorldTickEvent evt)
{
if (ENABLED && evt.side == Side.SERVER && evt.phase == TickEvent.Phase.END)
{
if (evt.world.getWorldTime() % 60 == 0)
{
for (EntityItemFrame frame : FRAMES)
{
if (!frame.isDead && !frame.getDisplayedItem().isEmpty() && frame.getDisplayedItem().getItem() == Items.STICK)
{
NET.sendToAllTracking(new TestEntityMessage(), frame);
}
}
}
}
}
public static class TestEntityMessage implements IMessage
{
@Override
public void fromBytes(ByteBuf buf) {}
@Override
public void toBytes(ByteBuf buf) {}
}
public static class TestEntityMessageHandler implements IMessageHandler<TestEntityMessage, IMessage>
{
@Override
public IMessage onMessage(TestEntityMessage message, MessageContext ctx)
{
LOGGER.info("Received tracking point test entity message");
return null;
}
}
}
*/

View File

@ -1,25 +0,0 @@
/*
* Minecraft Forge
* Copyright (c) 2016-2019.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation version 2.1
* of the License.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
@ParametersAreNonnullByDefault
@MethodsReturnNonnullByDefault
package net.minecraftforge.debug.network;
import javax.annotation.ParametersAreNonnullByDefault;
import mcp.MethodsReturnNonnullByDefault;

Some files were not shown because too many files have changed in this diff Show More