diff --git a/src/test/java/net/minecraftforge/debug/block/CustomTNTTest.java b/src/test/java/net/minecraftforge/debug/block/CustomTNTTest.java deleted file mode 100644 index c584f82187..0000000000 --- a/src/test/java/net/minecraftforge/debug/block/CustomTNTTest.java +++ /dev/null @@ -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 BLOCKS = new DeferredRegister<>(ForgeRegistries.BLOCKS, MODID); - private static final DeferredRegister ITEMS = new DeferredRegister<>(ForgeRegistries.ITEMS, MODID); - private static final DeferredRegister> ENTITIES = new DeferredRegister<>(ForgeRegistries.ENTITIES, MODID); - - public static final RegistryObject CUSTOM_TNT = BLOCKS.register(BLOCK_ID, () -> new CustomTNTBlock(Block.Properties.from(Blocks.TNT))); - public static final RegistryObject> CUSTOM_TNT_ENTITY = ENTITIES.register(BLOCK_ID, () -> EntityType.Builder - .create((EntityType.IFactory) 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 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); - } - } -} - */ diff --git a/src/test/java/net/minecraftforge/debug/block/FarmlandWaterTest.java b/src/test/java/net/minecraftforge/debug/block/FarmlandWaterTest.java deleted file mode 100644 index 154f261ae1..0000000000 --- a/src/test/java/net/minecraftforge/debug/block/FarmlandWaterTest.java +++ /dev/null @@ -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 test_tile = null; - - @SubscribeEvent - public static void registerBlocks(RegistryEvent.Register event) - { - event.getRegistry().register(new TestBlock(Block.Properties.create(Material.ROCK)).setRegistryName(MOD_ID, BLOCK_ID)); - } - - @SubscribeEvent - public static void registerTileEntity(RegistryEvent.Register> 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 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 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 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(); - } - } - } -} -*/ diff --git a/src/test/java/net/minecraftforge/debug/block/MaterialFogColorTest.java b/src/test/java/net/minecraftforge/debug/block/MaterialFogColorTest.java deleted file mode 100644 index 1ec7063fae..0000000000 --- a/src/test/java/net/minecraftforge/debug/block/MaterialFogColorTest.java +++ /dev/null @@ -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 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 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; - } - }); - } - } - */ -} diff --git a/src/test/java/net/minecraftforge/debug/block/ParticleEffectsTest.java b/src/test/java/net/minecraftforge/debug/block/ParticleEffectsTest.java deleted file mode 100644 index 130b81256e..0000000000 --- a/src/test/java/net/minecraftforge/debug/block/ParticleEffectsTest.java +++ /dev/null @@ -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 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 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); - } - } - *//* - -} -*/ diff --git a/src/test/java/net/minecraftforge/debug/block/PathNodeTypeTest.java b/src/test/java/net/minecraftforge/debug/block/PathNodeTypeTest.java deleted file mode 100644 index 1553d75f61..0000000000 --- a/src/test/java/net/minecraftforge/debug/block/PathNodeTypeTest.java +++ /dev/null @@ -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 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)); - } - } - } - */ -} diff --git a/src/test/java/net/minecraftforge/debug/block/PortalSpawnEventTest.java b/src/test/java/net/minecraftforge/debug/block/PortalSpawnEventTest.java deleted file mode 100644 index 6aa62e3346..0000000000 --- a/src/test/java/net/minecraftforge/debug/block/PortalSpawnEventTest.java +++ /dev/null @@ -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); - } -} -*/ diff --git a/src/test/java/net/minecraftforge/debug/chat/ClientCommandTest.java b/src/test/java/net/minecraftforge/debug/chat/ClientCommandTest.java deleted file mode 100644 index 786d47ca4b..0000000000 --- a/src/test/java/net/minecraftforge/debug/chat/ClientCommandTest.java +++ /dev/null @@ -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 "; - } - - @Override - public boolean checkPermission(MinecraftServer server, ICommandSender sender) - { - return true; - } - - @Override - public List 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.")); - } - } - } - */ -} diff --git a/src/test/java/net/minecraftforge/debug/client/CustomTextureAtlasSpriteTest.java b/src/test/java/net/minecraftforge/debug/client/CustomTextureAtlasSpriteTest.java deleted file mode 100644 index 8fecd4a552..0000000000 --- a/src/test/java/net/minecraftforge/debug/client/CustomTextureAtlasSpriteTest.java +++ /dev/null @@ -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 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 getDependencies() - { - return ImmutableList.of(delegate); - } - - @Override - public boolean load(@Nonnull IResourceManager manager, @Nonnull ResourceLocation location, @Nonnull Function 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; - } - } -} -*/ diff --git a/src/test/java/net/minecraftforge/debug/client/FOVModifierEventTest.java b/src/test/java/net/minecraftforge/debug/client/FOVModifierEventTest.java deleted file mode 100644 index 07dd7ea215..0000000000 --- a/src/test/java/net/minecraftforge/debug/client/FOVModifierEventTest.java +++ /dev/null @@ -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); - } - } -} -*/ diff --git a/src/test/java/net/minecraftforge/debug/client/SearchableCreativeTabTest.java b/src/test/java/net/minecraftforge/debug/client/SearchableCreativeTabTest.java deleted file mode 100644 index 875b2c78ee..0000000000 --- a/src/test/java/net/minecraftforge/debug/client/SearchableCreativeTabTest.java +++ /dev/null @@ -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 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)); - } - }; -} -*/ diff --git a/src/test/java/net/minecraftforge/debug/client/gui/ContainerDrawForegroundEventTest.java b/src/test/java/net/minecraftforge/debug/client/gui/ContainerDrawForegroundEventTest.java deleted file mode 100644 index 087336724b..0000000000 --- a/src/test/java/net/minecraftforge/debug/client/gui/ContainerDrawForegroundEventTest.java +++ /dev/null @@ -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(); - } - } - } - -} -*/ diff --git a/src/test/java/net/minecraftforge/debug/client/gui/TooltipColorEventTest.java b/src/test/java/net/minecraftforge/debug/client/gui/TooltipColorEventTest.java deleted file mode 100644 index b7b060fb57..0000000000 --- a/src/test/java/net/minecraftforge/debug/client/gui/TooltipColorEventTest.java +++ /dev/null @@ -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); - } - } -}*/ diff --git a/src/test/java/net/minecraftforge/debug/client/model/AnimatedModelTest.java b/src/test/java/net/minecraftforge/debug/client/model/AnimatedModelTest.java deleted file mode 100644 index b7ae6a8ad1..0000000000 --- a/src/test/java/net/minecraftforge/debug/client/model/AnimatedModelTest.java +++ /dev/null @@ -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 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 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 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 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() - { - @Override - public void handleEvents(Chest chest, float time, Iterable pastEvents) - { - chest.handleEvents(time, pastEvents); - } - }); - ModelLoader.setCustomModelResourceLocation(TEST_ROTATE_ITEM, 0, new ModelResourceLocation(TEST_ROTATE_ITEM.getRegistryName(), "inventory")); - ClientRegistry.bindTileEntitySpecialRenderer(Spin.class, new AnimationTESR()); - 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() - { - @SuppressWarnings("deprecation") - public Render 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(manager, new net.minecraftforge.client.model.animation.AnimationModelBase(location, new VertexLighterSmoothAo(Minecraft.getMinecraft().getBlockColors())) - { - @Override - public void handleEvents(EntityChest chest, float time, Iterable 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.of( - "cycle_length", cycleLength - )); - - @Override - public boolean hasCapability(@Nonnull Capability capability, @Nullable EnumFacing facing) - { - return capability == CapabilityAnimation.ANIMATION_CAPABILITY; - } - - @Override - @Nullable - public T getCapability(@Nonnull Capability 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 getCapability(@Nonnull Capability 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.of( - "click_time", clickTime - ));*//* - - asm = proxy.load(new ResourceLocation(MODID.toLowerCase(), "asms/block/engine.json"), ImmutableMap.of( - "cycle_length", cycleLength, - "click_time", clickTime - //"offset", offset - )); - } - - public void handleEvents(float time, Iterable 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 getCapability(@Nonnull Capability 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.of( - "cycle_length", cycleLength - )); - } - - public void handleEvents(float time, Iterable 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 getCapability(@Nonnull Capability capability, @Nullable EnumFacing side) - { - if (capability == CapabilityAnimation.ANIMATION_CAPABILITY) - { - return CapabilityAnimation.ANIMATION_CAPABILITY.cast(asm); - } - return super.getCapability(capability, side); - } - } -} - -*/ diff --git a/src/test/java/net/minecraftforge/debug/client/model/ItemLayerModelTest.java b/src/test/java/net/minecraftforge/debug/client/model/ItemLayerModelTest.java deleted file mode 100644 index 5ea36440d7..0000000000 --- a/src/test/java/net/minecraftforge/debug/client/model/ItemLayerModelTest.java +++ /dev/null @@ -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 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; - } - } -} -*/ diff --git a/src/test/java/net/minecraftforge/debug/client/model/ItemModelConflictTest.java b/src/test/java/net/minecraftforge/debug/client/model/ItemModelConflictTest.java deleted file mode 100644 index 0444112a17..0000000000 --- a/src/test/java/net/minecraftforge/debug/client/model/ItemModelConflictTest.java +++ /dev/null @@ -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 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 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")); - } - } -} -*/ diff --git a/src/test/java/net/minecraftforge/debug/client/model/ItemModelGenerationTest.java b/src/test/java/net/minecraftforge/debug/client/model/ItemModelGenerationTest.java deleted file mode 100644 index c80354030b..0000000000 --- a/src/test/java/net/minecraftforge/debug/client/model/ItemModelGenerationTest.java +++ /dev/null @@ -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 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")); - } - } -} -*/ diff --git a/src/test/java/net/minecraftforge/debug/client/model/ModelBakeEventTest.java b/src/test/java/net/minecraftforge/debug/client/model/ModelBakeEventTest.java deleted file mode 100644 index f46cff3f11..0000000000 --- a/src/test/java/net/minecraftforge/debug/client/model/ModelBakeEventTest.java +++ /dev/null @@ -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[] 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 event) - { - event.getRegistry().register(new CustomModelBlock()); - GameRegistry.registerTileEntity(CustomTileEntity.class, MODID.toLowerCase() + ":custom_tile_entity"); - } - - @SubscribeEvent - public static void registerItems(RegistryEvent.Register 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 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 ret = new ArrayList(); - 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 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); - } -} -*/ diff --git a/src/test/java/net/minecraftforge/debug/client/model/ModelDataTest.java b/src/test/java/net/minecraftforge/debug/client/model/ModelDataTest.java deleted file mode 100644 index 1c90b41587..0000000000 --- a/src/test/java/net/minecraftforge/debug/client/model/ModelDataTest.java +++ /dev/null @@ -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 MAGIC_PROP = new ModelProperty(); - 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_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 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 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> event) - { - event.getRegistry().register(TileEntityType.Builder.func_223042_a(Tile::new, MY_BLOCK).build(null).setRegistryName(MODID, BLOCK_NAME)); - } -} -*/ diff --git a/src/test/java/net/minecraftforge/debug/client/model/ModelFluidTest.java b/src/test/java/net/minecraftforge/debug/client/model/ModelFluidTest.java deleted file mode 100644 index 2616d1ba61..0000000000 --- a/src/test/java/net/minecraftforge/debug/client/model/ModelFluidTest.java +++ /dev/null @@ -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 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 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)); - } - } -} -*/ diff --git a/src/test/java/net/minecraftforge/debug/client/model/ModelLoaderRegistryTest.java b/src/test/java/net/minecraftforge/debug/client/model/ModelLoaderRegistryTest.java deleted file mode 100644 index 6fba8d038c..0000000000 --- a/src/test/java/net/minecraftforge/debug/client/model/ModelLoaderRegistryTest.java +++ /dev/null @@ -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 TESSERACT_TILE = null; - //@ObjectHolder(OBJVertexColoring2.name) - public static final TileEntityType 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 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> 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 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 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 hidden = new ArrayList(); - private final IModelState state = new IModelState() - { - private final Optional value = Optional.of(TransformationMatrix.identity()); - - @Override - public Optional apply(Optional part) - { - if (part.isPresent()) - { - // This whole thing is subject to change, but should do for now. - UnmodifiableIterator 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 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 colorList = new ArrayList(); - 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 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 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 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); - } - } - } -} -*/ diff --git a/src/test/java/net/minecraftforge/debug/client/package-info.java b/src/test/java/net/minecraftforge/debug/client/package-info.java deleted file mode 100644 index 31d2fe62bb..0000000000 --- a/src/test/java/net/minecraftforge/debug/client/package-info.java +++ /dev/null @@ -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; diff --git a/src/test/java/net/minecraftforge/debug/client/rendering/FastTESRTransparentTest.java b/src/test/java/net/minecraftforge/debug/client/rendering/FastTESRTransparentTest.java deleted file mode 100644 index 3b5c3457c8..0000000000 --- a/src/test/java/net/minecraftforge/debug/client/rendering/FastTESRTransparentTest.java +++ /dev/null @@ -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 - { - - 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 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 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 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 evt) - { - evt.getRegistry().register(testBlock - .setCreativeTab(CreativeTabs.DECORATIONS) - .setRegistryName("fluid-tesr-block")); - } - - @net.minecraftforge.eventbus.api.SubscribeEvent - public static void onItemRegister(RegistryEvent.Register evt) - { - evt.getRegistry().register(new ItemBlock(testBlock) - { - @Override - public void addInformation(ItemStack stack, World worldIn, List tooltip, ITooltipFlag flagIn) - { - final Optional 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()); - } - } -} -*/ diff --git a/src/test/java/net/minecraftforge/debug/client/rendering/ItemTESRTest.java b/src/test/java/net/minecraftforge/debug/client/rendering/ItemTESRTest.java deleted file mode 100644 index c7f092a0c5..0000000000 --- a/src/test/java/net/minecraftforge/debug/client/rendering/ItemTESRTest.java +++ /dev/null @@ -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 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 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 - { - 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 - { - } -} -*/ diff --git a/src/test/java/net/minecraftforge/debug/client/rendering/VertexBufferNormalTest.java b/src/test/java/net/minecraftforge/debug/client/rendering/VertexBufferNormalTest.java deleted file mode 100644 index cc0e0b396d..0000000000 --- a/src/test/java/net/minecraftforge/debug/client/rendering/VertexBufferNormalTest.java +++ /dev/null @@ -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 - { - @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 - { - 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); - } - } -} -*/ diff --git a/src/test/java/net/minecraftforge/debug/entity/BlockEntityUpdateTest.java b/src/test/java/net/minecraftforge/debug/entity/BlockEntityUpdateTest.java deleted file mode 100644 index 78298f54c0..0000000000 --- a/src/test/java/net/minecraftforge/debug/entity/BlockEntityUpdateTest.java +++ /dev/null @@ -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 "; - } - - @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; - } - } - } - } -} -*/ diff --git a/src/test/java/net/minecraftforge/debug/entity/EntityTravelToDimensionEventTest.java b/src/test/java/net/minecraftforge/debug/entity/EntityTravelToDimensionEventTest.java deleted file mode 100644 index 46f750c99e..0000000000 --- a/src/test/java/net/minecraftforge/debug/entity/EntityTravelToDimensionEventTest.java +++ /dev/null @@ -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); - } - } -} -*/ diff --git a/src/test/java/net/minecraftforge/debug/entity/GetCollisionBoxesEventTest.java b/src/test/java/net/minecraftforge/debug/entity/GetCollisionBoxesEventTest.java deleted file mode 100644 index 99b8864d46..0000000000 --- a/src/test/java/net/minecraftforge/debug/entity/GetCollisionBoxesEventTest.java +++ /dev/null @@ -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 locations = new ArrayList<>(); - - @net.minecraftforge.eventbus.api.SubscribeEvent - public static void registerBlock(RegistryEvent.Register event) - { - if (ENABLED) - { - event.getRegistry().register(new BoxBlock()); - } - } - - @SubscribeEvent - public static void registerItem(RegistryEvent.Register 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"; - } - - } -}*/ diff --git a/src/test/java/net/minecraftforge/debug/entity/ProjectileImpactEventTest.java b/src/test/java/net/minecraftforge/debug/entity/ProjectileImpactEventTest.java deleted file mode 100644 index 331d25b305..0000000000 --- a/src/test/java/net/minecraftforge/debug/entity/ProjectileImpactEventTest.java +++ /dev/null @@ -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()); - } -} -*/ diff --git a/src/test/java/net/minecraftforge/debug/entity/living/AnimalTameEventTest.java b/src/test/java/net/minecraftforge/debug/entity/living/AnimalTameEventTest.java deleted file mode 100644 index 2827163850..0000000000 --- a/src/test/java/net/minecraftforge/debug/entity/living/AnimalTameEventTest.java +++ /dev/null @@ -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); - } - } -} -*/ diff --git a/src/test/java/net/minecraftforge/debug/entity/living/AttackEventTest.java b/src/test/java/net/minecraftforge/debug/entity/living/AttackEventTest.java deleted file mode 100644 index ae272b250e..0000000000 --- a/src/test/java/net/minecraftforge/debug/entity/living/AttackEventTest.java +++ /dev/null @@ -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()); - } - } - } -} -*/ diff --git a/src/test/java/net/minecraftforge/debug/entity/living/BabyEntitySpawnEventTest.java b/src/test/java/net/minecraftforge/debug/entity/living/BabyEntitySpawnEventTest.java deleted file mode 100644 index 3208dece6a..0000000000 --- a/src/test/java/net/minecraftforge/debug/entity/living/BabyEntitySpawnEventTest.java +++ /dev/null @@ -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)); - } -} -*/ diff --git a/src/test/java/net/minecraftforge/debug/entity/living/CheckSpawnEventTest.java b/src/test/java/net/minecraftforge/debug/entity/living/CheckSpawnEventTest.java deleted file mode 100644 index 38f18cd6eb..0000000000 --- a/src/test/java/net/minecraftforge/debug/entity/living/CheckSpawnEventTest.java +++ /dev/null @@ -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); - } -} -*/ diff --git a/src/test/java/net/minecraftforge/debug/entity/living/CustomSpawnPlacementTest.java b/src/test/java/net/minecraftforge/debug/entity/living/CustomSpawnPlacementTest.java deleted file mode 100644 index 81c182c5ac..0000000000 --- a/src/test/java/net/minecraftforge/debug/entity/living/CustomSpawnPlacementTest.java +++ /dev/null @@ -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); - } - } -} -*/ diff --git a/src/test/java/net/minecraftforge/debug/entity/living/DamageEventTest.java b/src/test/java/net/minecraftforge/debug/entity/living/DamageEventTest.java deleted file mode 100644 index 9f8d701c52..0000000000 --- a/src/test/java/net/minecraftforge/debug/entity/living/DamageEventTest.java +++ /dev/null @@ -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 DAMAGE_SOURCES = ImmutableMap. 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 "; - - @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 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()); - } - - } -} -*/ diff --git a/src/test/java/net/minecraftforge/debug/entity/living/EquipmentChangeEventTest.java b/src/test/java/net/minecraftforge/debug/entity/living/EquipmentChangeEventTest.java deleted file mode 100644 index bf5747a691..0000000000 --- a/src/test/java/net/minecraftforge/debug/entity/living/EquipmentChangeEventTest.java +++ /dev/null @@ -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()); - } - -} -*/ diff --git a/src/test/java/net/minecraftforge/debug/entity/living/KnockBackEventTest.java b/src/test/java/net/minecraftforge/debug/entity/living/KnockBackEventTest.java deleted file mode 100644 index bca868c572..0000000000 --- a/src/test/java/net/minecraftforge/debug/entity/living/KnockBackEventTest.java +++ /dev/null @@ -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); - } - } - } -}*/ diff --git a/src/test/java/net/minecraftforge/debug/entity/living/MobGriefingEventTest.java b/src/test/java/net/minecraftforge/debug/entity/living/MobGriefingEventTest.java deleted file mode 100644 index 13d9a25112..0000000000 --- a/src/test/java/net/minecraftforge/debug/entity/living/MobGriefingEventTest.java +++ /dev/null @@ -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. - } - } - } -} -*/ diff --git a/src/test/java/net/minecraftforge/debug/entity/living/SpecialSpawnTest.java b/src/test/java/net/minecraftforge/debug/entity/living/SpecialSpawnTest.java deleted file mode 100644 index 92a4d17d0f..0000000000 --- a/src/test/java/net/minecraftforge/debug/entity/living/SpecialSpawnTest.java +++ /dev/null @@ -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"); - } - } -}*/ diff --git a/src/test/java/net/minecraftforge/debug/entity/living/VillagerProfessionTest.java b/src/test/java/net/minecraftforge/debug/entity/living/VillagerProfessionTest.java deleted file mode 100644 index 73bd299deb..0000000000 --- a/src/test/java/net/minecraftforge/debug/entity/living/VillagerProfessionTest.java +++ /dev/null @@ -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 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); - } -} -*/ diff --git a/src/test/java/net/minecraftforge/debug/entity/living/package-info.java b/src/test/java/net/minecraftforge/debug/entity/living/package-info.java deleted file mode 100644 index 40c3d1a9b3..0000000000 --- a/src/test/java/net/minecraftforge/debug/entity/living/package-info.java +++ /dev/null @@ -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; diff --git a/src/test/java/net/minecraftforge/debug/entity/player/CriticalHitEventTest.java b/src/test/java/net/minecraftforge/debug/entity/player/CriticalHitEventTest.java deleted file mode 100644 index 6214783e14..0000000000 --- a/src/test/java/net/minecraftforge/debug/entity/player/CriticalHitEventTest.java +++ /dev/null @@ -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()); - } -} -*/ diff --git a/src/test/java/net/minecraftforge/debug/entity/player/DamageReworkTest.java b/src/test/java/net/minecraftforge/debug/entity/player/DamageReworkTest.java deleted file mode 100644 index 4379b0b080..0000000000 --- a/src/test/java/net/minecraftforge/debug/entity/player/DamageReworkTest.java +++ /dev/null @@ -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); - } - } - } -}*/ diff --git a/src/test/java/net/minecraftforge/debug/entity/player/ItemPickupEventTest.java b/src/test/java/net/minecraftforge/debug/entity/player/ItemPickupEventTest.java deleted file mode 100644 index 8bddd579f0..0000000000 --- a/src/test/java/net/minecraftforge/debug/entity/player/ItemPickupEventTest.java +++ /dev/null @@ -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()); - } -} -*/ diff --git a/src/test/java/net/minecraftforge/debug/entity/player/PlayerInteractEventTest.java b/src/test/java/net/minecraftforge/debug/entity/player/PlayerInteractEventTest.java deleted file mode 100644 index a1493ffd86..0000000000 --- a/src/test/java/net/minecraftforge/debug/entity/player/PlayerInteractEventTest.java +++ /dev/null @@ -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); - } - } - } -} -*/ diff --git a/src/test/java/net/minecraftforge/debug/entity/player/PlayerSetSpawnTest.java b/src/test/java/net/minecraftforge/debug/entity/player/PlayerSetSpawnTest.java deleted file mode 100644 index ccefd7e898..0000000000 --- a/src/test/java/net/minecraftforge/debug/entity/player/PlayerSetSpawnTest.java +++ /dev/null @@ -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); - } -} -*/ diff --git a/src/test/java/net/minecraftforge/debug/entity/player/ReachDistanceAttributeTest.java b/src/test/java/net/minecraftforge/debug/entity/player/ReachDistanceAttributeTest.java deleted file mode 100644 index 56ac00d606..0000000000 --- a/src/test/java/net/minecraftforge/debug/entity/player/ReachDistanceAttributeTest.java +++ /dev/null @@ -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 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 getAttributeModifiers(EntityEquipmentSlot slot, ItemStack stack) - { - Multimap attribs = super.getAttributeModifiers(slot, stack); - if (slot == this.armorType) - { - attribs.put(EntityPlayer.REACH_DISTANCE.getName(), BOOST); - } - return attribs; - } - } -} -*/ diff --git a/src/test/java/net/minecraftforge/debug/entity/player/SwimSpeedAttributeTest.java b/src/test/java/net/minecraftforge/debug/entity/player/SwimSpeedAttributeTest.java deleted file mode 100644 index 6c25d8cdc4..0000000000 --- a/src/test/java/net/minecraftforge/debug/entity/player/SwimSpeedAttributeTest.java +++ /dev/null @@ -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 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 getAttributeModifiers(EntityEquipmentSlot slot, ItemStack stack) - { - Multimap attribs = super.getAttributeModifiers(slot, stack); - if (slot == this.armorType) - { - attribs.put(EntityLivingBase.SWIM_SPEED.getName(), BOOST); - } - return attribs; - } - } -} -*/ diff --git a/src/test/java/net/minecraftforge/debug/fluid/ColoredFluidTest.java b/src/test/java/net/minecraftforge/debug/fluid/ColoredFluidTest.java deleted file mode 100644 index 74f2c53543..0000000000 --- a/src/test/java/net/minecraftforge/debug/fluid/ColoredFluidTest.java +++ /dev/null @@ -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 event) - { - if (ENABLED) - { - event.getRegistry().register((new BlockFluidClassic(SLIME, Material.WATER)).setRegistryName(RES_LOC).setUnlocalizedName(RES_LOC.toString())); - } - } -} -*/ diff --git a/src/test/java/net/minecraftforge/debug/fluid/CreateFluidSourceEventTest.java b/src/test/java/net/minecraftforge/debug/fluid/CreateFluidSourceEventTest.java deleted file mode 100644 index 4cc1ba75b0..0000000000 --- a/src/test/java/net/minecraftforge/debug/fluid/CreateFluidSourceEventTest.java +++ /dev/null @@ -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); - } - } -} -*/ diff --git a/src/test/java/net/minecraftforge/debug/fluid/DynBucketTest.java b/src/test/java/net/minecraftforge/debug/fluid/DynBucketTest.java deleted file mode 100644 index 01e51ca239..0000000000 --- a/src/test/java/net/minecraftforge/debug/fluid/DynBucketTest.java +++ /dev/null @@ -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 event) - { - event.getRegistry().register(new BlockSimpleTank().setRegistryName(simpleTankName)); - GameRegistry.registerTileEntity(TileSimpleTank.class, "simpletank"); - } - - @net.minecraftforge.eventbus.api.SubscribeEvent - public void registerItems(RegistryEvent.Register 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 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 onItemRightClick(World worldIn, EntityPlayer playerIn, EnumHand hand) - { - ItemStack itemStackIn = playerIn.getHeldItem(hand); - if (worldIn.isRemote) - { - return new ActionResult(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(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 getCapability(@Nonnull Capability capability, @Nullable EnumFacing facing) - { - if (capability == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY) - { - return CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY.cast(tank); - } - return super.getCapability(capability, facing); - } - } -} -*/ diff --git a/src/test/java/net/minecraftforge/debug/fluid/FluidPlaceBlockEventTest.java b/src/test/java/net/minecraftforge/debug/fluid/FluidPlaceBlockEventTest.java deleted file mode 100644 index d3eebfafda..0000000000 --- a/src/test/java/net/minecraftforge/debug/fluid/FluidPlaceBlockEventTest.java +++ /dev/null @@ -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()); - } -} -*/ diff --git a/src/test/java/net/minecraftforge/debug/fluid/FluidPlacementTest.java b/src/test/java/net/minecraftforge/debug/fluid/FluidPlacementTest.java deleted file mode 100644 index 96e51ce794..0000000000 --- a/src/test/java/net/minecraftforge/debug/fluid/FluidPlacementTest.java +++ /dev/null @@ -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 event) - { - if (!ENABLE || !ModelFluidTest.ENABLE) - return; - event.getRegistry().registerAll( - FiniteFluidBlock.instance - ); - } - - @SubscribeEvent - public static void registerItems(RegistryEvent.Register 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 tooltip, ITooltipFlag advanced) - { - FluidStack fluid = getFluid(stack); - if (fluid != null) - { - tooltip.add(fluid.amount + "/1000"); - } - } - - @Override - public void getSubItems(@Nullable CreativeTabs tab, @Nonnull NonNullList 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); - } - } -} -*/ diff --git a/src/test/java/net/minecraftforge/debug/fluid/ItemFluidHandlerTest.java b/src/test/java/net/minecraftforge/debug/fluid/ItemFluidHandlerTest.java deleted file mode 100644 index 188b2d9f9a..0000000000 --- a/src/test/java/net/minecraftforge/debug/fluid/ItemFluidHandlerTest.java +++ /dev/null @@ -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 getAllItems() - { - NonNullList list = NonNullList.create(); - for (Item item : ForgeRegistries.ITEMS.getValuesCollection()) - { - for (CreativeTabs tab : item.getCreativeTabs()) - { - item.getSubItems(tab, list); - } - } - return list; - } -} -*/ diff --git a/src/test/java/net/minecraftforge/debug/gameplay/AnytimeSleepingTest.java b/src/test/java/net/minecraftforge/debug/gameplay/AnytimeSleepingTest.java deleted file mode 100644 index 16aaa523af..0000000000 --- a/src/test/java/net/minecraftforge/debug/gameplay/AnytimeSleepingTest.java +++ /dev/null @@ -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 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)); - } - } -} -*/ diff --git a/src/test/java/net/minecraftforge/debug/gameplay/BrewingRecipeRegistryTest.java b/src/test/java/net/minecraftforge/debug/gameplay/BrewingRecipeRegistryTest.java deleted file mode 100644 index bd0ecb74a1..0000000000 --- a/src/test/java/net/minecraftforge/debug/gameplay/BrewingRecipeRegistryTest.java +++ /dev/null @@ -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"); - } - } -} -*/ diff --git a/src/test/java/net/minecraftforge/debug/gameplay/ConstantLoadingTest.java b/src/test/java/net/minecraftforge/debug/gameplay/ConstantLoadingTest.java deleted file mode 100644 index d17cf4fb3f..0000000000 --- a/src/test/java/net/minecraftforge/debug/gameplay/ConstantLoadingTest.java +++ /dev/null @@ -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 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"); - } - } -} -*/ diff --git a/src/test/java/net/minecraftforge/debug/gameplay/CraftingSystemTest.java b/src/test/java/net/minecraftforge/debug/gameplay/CraftingSystemTest.java deleted file mode 100644 index 189a796325..0000000000 --- a/src/test/java/net/minecraftforge/debug/gameplay/CraftingSystemTest.java +++ /dev/null @@ -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 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; - } - } -} -*/ diff --git a/src/test/java/net/minecraftforge/debug/gameplay/DifficultyChangeEventTest.java b/src/test/java/net/minecraftforge/debug/gameplay/DifficultyChangeEventTest.java deleted file mode 100644 index 41070f5aef..0000000000 --- a/src/test/java/net/minecraftforge/debug/gameplay/DifficultyChangeEventTest.java +++ /dev/null @@ -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()); - } -}*/ diff --git a/src/test/java/net/minecraftforge/debug/gameplay/DynamicBannerTest.java b/src/test/java/net/minecraftforge/debug/gameplay/DynamicBannerTest.java deleted file mode 100644 index a8410e272f..0000000000 --- a/src/test/java/net/minecraftforge/debug/gameplay/DynamicBannerTest.java +++ /dev/null @@ -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 itemList) - { - super.displayAllRelevantItems(itemList); - - for (final BannerPattern pattern : BannerPattern.values()) - itemList.add(ItemBanner.makeBanner(EnumDyeColor.WHITE, makePatternNBTList(pattern, EnumDyeColor.BLACK))); - } - } -} -*/ diff --git a/src/test/java/net/minecraftforge/debug/gameplay/EnchantmentLevelSetEventTest.java b/src/test/java/net/minecraftforge/debug/gameplay/EnchantmentLevelSetEventTest.java deleted file mode 100644 index 7691c52d8a..0000000000 --- a/src/test/java/net/minecraftforge/debug/gameplay/EnchantmentLevelSetEventTest.java +++ /dev/null @@ -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()); - } -} -*/ diff --git a/src/test/java/net/minecraftforge/debug/gameplay/FurnaceFuelBurnTimeEventTest.java b/src/test/java/net/minecraftforge/debug/gameplay/FurnaceFuelBurnTimeEventTest.java deleted file mode 100644 index e709a1904e..0000000000 --- a/src/test/java/net/minecraftforge/debug/gameplay/FurnaceFuelBurnTimeEventTest.java +++ /dev/null @@ -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 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"; - } - } -} -*/ diff --git a/src/test/java/net/minecraftforge/debug/gameplay/GiveItemToPlayerTest.java b/src/test/java/net/minecraftforge/debug/gameplay/GiveItemToPlayerTest.java deleted file mode 100644 index 6f3767a7e7..0000000000 --- a/src/test/java/net/minecraftforge/debug/gameplay/GiveItemToPlayerTest.java +++ /dev/null @@ -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); - } -} -*/ diff --git a/src/test/java/net/minecraftforge/debug/gameplay/InputUpdateEventTest.java b/src/test/java/net/minecraftforge/debug/gameplay/InputUpdateEventTest.java deleted file mode 100644 index 877d90a782..0000000000 --- a/src/test/java/net/minecraftforge/debug/gameplay/InputUpdateEventTest.java +++ /dev/null @@ -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; - } - } - } - } - -} -*/ diff --git a/src/test/java/net/minecraftforge/debug/gameplay/NoBedSleepingTest.java b/src/test/java/net/minecraftforge/debug/gameplay/NoBedSleepingTest.java deleted file mode 100644 index 04f62ad19b..0000000000 --- a/src/test/java/net/minecraftforge/debug/gameplay/NoBedSleepingTest.java +++ /dev/null @@ -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 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 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 evt) - { - if (!(evt.getObject() instanceof EntityPlayer)) - { - return; - } - - evt.addCapability(new ResourceLocation(MODID, "IExtraSleeping"), new ICapabilitySerializable() - { - IExtraSleeping inst = SLEEP_CAP.getDefaultInstance(); - - @Override - public boolean hasCapability(@Nonnull Capability capability, @Nullable EnumFacing facing) - { - return capability == SLEEP_CAP; - } - - @Override - @Nullable - public T getCapability(@Nonnull Capability capability, @Nullable EnumFacing facing) - { - return capability == SLEEP_CAP ? SLEEP_CAP.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 - { - @Override - public NBTBase writeNBT(Capability capability, IExtraSleeping instance, EnumFacing side) - { - return new NBTTagByte((byte) (instance.isSleeping() ? 1 : 0)); - } - - @Override - public void readNBT(Capability 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 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); - } - } -} -*/ diff --git a/src/test/java/net/minecraftforge/debug/gameplay/PotionRegistryTest.java b/src/test/java/net/minecraftforge/debug/gameplay/PotionRegistryTest.java deleted file mode 100644 index a47841a772..0000000000 --- a/src/test/java/net/minecraftforge/debug/gameplay/PotionRegistryTest.java +++ /dev/null @@ -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 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(); - } - } -} -*/ diff --git a/src/test/java/net/minecraftforge/debug/gameplay/RecipeMatchingTest.java b/src/test/java/net/minecraftforge/debug/gameplay/RecipeMatchingTest.java deleted file mode 100644 index 0f13c4707e..0000000000 --- a/src/test/java/net/minecraftforge/debug/gameplay/RecipeMatchingTest.java +++ /dev/null @@ -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 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 event) - { - proxy.registerItem(event); - } - - public static abstract class CommonProxy - { - protected Item TOOL; - public void registerItem(RegistryEvent.Register 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 event) - { - super.registerItem(event); - ModelLoader.setCustomModelResourceLocation(TOOL, 0, new ModelResourceLocation("minecraft:stick#inventory")); - } - } -} -*/ diff --git a/src/test/java/net/minecraftforge/debug/gameplay/advancement/AdvancementCriterionTest.java b/src/test/java/net/minecraftforge/debug/gameplay/advancement/AdvancementCriterionTest.java deleted file mode 100644 index 341b4efddd..0000000000 --- a/src/test/java/net/minecraftforge/debug/gameplay/advancement/AdvancementCriterionTest.java +++ /dev/null @@ -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); - } - } -} -*/ diff --git a/src/test/java/net/minecraftforge/debug/gameplay/advancement/AdvancementEventTest.java b/src/test/java/net/minecraftforge/debug/gameplay/advancement/AdvancementEventTest.java deleted file mode 100644 index e3b7941a33..0000000000 --- a/src/test/java/net/minecraftforge/debug/gameplay/advancement/AdvancementEventTest.java +++ /dev/null @@ -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()); - } - } -} -*/ diff --git a/src/test/java/net/minecraftforge/debug/gameplay/advancement/AdvancementsPaginationTest.java b/src/test/java/net/minecraftforge/debug/gameplay/advancement/AdvancementsPaginationTest.java deleted file mode 100644 index 585e8a305a..0000000000 --- a/src/test/java/net/minecraftforge/debug/gameplay/advancement/AdvancementsPaginationTest.java +++ /dev/null @@ -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 -{ -} diff --git a/src/test/java/net/minecraftforge/debug/gameplay/advancement/OredictTriggerTest.java b/src/test/java/net/minecraftforge/debug/gameplay/advancement/OredictTriggerTest.java deleted file mode 100644 index 1309251c4a..0000000000 --- a/src/test/java/net/minecraftforge/debug/gameplay/advancement/OredictTriggerTest.java +++ /dev/null @@ -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 expected…oh well. - *//* - - public static class EnabledTrigger implements ICriterionTrigger - { - public static final ResourceLocation ID = new ResourceLocation(MODID, "is_enabled"); - private final Map listeners = new HashMap<>(); - - @Override - public ResourceLocation getId() - { - return ID; - } - - @Override - public void addListener(PlayerAdvancements playerAdvancementsIn, Listener listener) - { - Listeners listeners = this.listeners.computeIfAbsent(playerAdvancementsIn, Listeners::new); - - listeners.add(listener); - } - - @Override - public void removeListener(PlayerAdvancements playerAdvancementsIn, Listener 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> listeners = new HashSet<>(); - - public Listeners(PlayerAdvancements playerAdvancementsIn) - { - this.playerAdvancements = playerAdvancementsIn; - } - - public boolean isEmpty() - { - return this.listeners.isEmpty(); - } - - public void add(ICriterionTrigger.Listener listener) - { - this.listeners.add(listener); - } - - public void remove(ICriterionTrigger.Listener listener) - { - this.listeners.remove(listener); - } - - public void trigger(InventoryPlayer inventory) - { - List> list = null; - - for (ICriterionTrigger.Listener listener : this.listeners) - { - if (ENABLED) - { - if (list == null) - { - list = new ArrayList<>(); - } - - list.add(listener); - } - } - - if (list != null) - { - for (ICriterionTrigger.Listener listener1 : list) - { - listener1.grantCriterion(this.playerAdvancements); - } - } - } - } - } -} -*/ diff --git a/src/test/java/net/minecraftforge/debug/gameplay/advancement/package-info.java b/src/test/java/net/minecraftforge/debug/gameplay/advancement/package-info.java deleted file mode 100644 index 6ea5e856bb..0000000000 --- a/src/test/java/net/minecraftforge/debug/gameplay/advancement/package-info.java +++ /dev/null @@ -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; diff --git a/src/test/java/net/minecraftforge/debug/gameplay/loot/LootContextTweaksTest.java b/src/test/java/net/minecraftforge/debug/gameplay/loot/LootContextTweaksTest.java deleted file mode 100644 index bea2874416..0000000000 --- a/src/test/java/net/minecraftforge/debug/gameplay/loot/LootContextTweaksTest.java +++ /dev/null @@ -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 - { - 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); - } - } - } -} -*/ diff --git a/src/test/java/net/minecraftforge/debug/gameplay/loot/LootTableLoadEventTest.java b/src/test/java/net/minecraftforge/debug/gameplay/loot/LootTableLoadEventTest.java deleted file mode 100644 index 0767d625fa..0000000000 --- a/src/test/java/net/minecraftforge/debug/gameplay/loot/LootTableLoadEventTest.java +++ /dev/null @@ -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); - } - } -} -*/ diff --git a/src/test/java/net/minecraftforge/debug/gameplay/loot/LootTableTest.java b/src/test/java/net/minecraftforge/debug/gameplay/loot/LootTableTest.java deleted file mode 100644 index 690e165029..0000000000 --- a/src/test/java/net/minecraftforge/debug/gameplay/loot/LootTableTest.java +++ /dev/null @@ -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); - } - } -} -*/ diff --git a/src/test/java/net/minecraftforge/debug/gameplay/package-info.java b/src/test/java/net/minecraftforge/debug/gameplay/package-info.java deleted file mode 100644 index 3d6c6d9be1..0000000000 --- a/src/test/java/net/minecraftforge/debug/gameplay/package-info.java +++ /dev/null @@ -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; diff --git a/src/test/java/net/minecraftforge/debug/item/BonemealEventTest.java b/src/test/java/net/minecraftforge/debug/item/BonemealEventTest.java deleted file mode 100644 index c48dde6bd0..0000000000 --- a/src/test/java/net/minecraftforge/debug/item/BonemealEventTest.java +++ /dev/null @@ -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"); - } - } -} -*/ diff --git a/src/test/java/net/minecraftforge/debug/item/CanApplyAtEnchantingTableTest.java b/src/test/java/net/minecraftforge/debug/item/CanApplyAtEnchantingTableTest.java deleted file mode 100644 index 9eb008b5f2..0000000000 --- a/src/test/java/net/minecraftforge/debug/item/CanApplyAtEnchantingTableTest.java +++ /dev/null @@ -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 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); - } - } - } -} -*/ diff --git a/src/test/java/net/minecraftforge/debug/item/CanDestroyBlocksInCreativeTest.java b/src/test/java/net/minecraftforge/debug/item/CanDestroyBlocksInCreativeTest.java deleted file mode 100644 index 8e24bf6e74..0000000000 --- a/src/test/java/net/minecraftforge/debug/item/CanDestroyBlocksInCreativeTest.java +++ /dev/null @@ -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 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); - } - } -} -*/ diff --git a/src/test/java/net/minecraftforge/debug/item/ContinuousUseItemTest.java b/src/test/java/net/minecraftforge/debug/item/ContinuousUseItemTest.java deleted file mode 100644 index 753e1df071..0000000000 --- a/src/test/java/net/minecraftforge/debug/item/ContinuousUseItemTest.java +++ /dev/null @@ -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 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 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(); - } - } -} -*/ diff --git a/src/test/java/net/minecraftforge/debug/item/HorseArmorTest.java b/src/test/java/net/minecraftforge/debug/item/HorseArmorTest.java deleted file mode 100644 index f807077195..0000000000 --- a/src/test/java/net/minecraftforge/debug/item/HorseArmorTest.java +++ /dev/null @@ -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 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)); - } - } -} -*/ diff --git a/src/test/java/net/minecraftforge/debug/item/IsBookEnchantableTest.java b/src/test/java/net/minecraftforge/debug/item/IsBookEnchantableTest.java deleted file mode 100644 index ec658ec7b5..0000000000 --- a/src/test/java/net/minecraftforge/debug/item/IsBookEnchantableTest.java +++ /dev/null @@ -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 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; - } - } -} -*/ diff --git a/src/test/java/net/minecraftforge/debug/item/ItemFishedEventTest.java b/src/test/java/net/minecraftforge/debug/item/ItemFishedEventTest.java deleted file mode 100644 index 4afb401c9c..0000000000 --- a/src/test/java/net/minecraftforge/debug/item/ItemFishedEventTest.java +++ /dev/null @@ -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); - } -} -*/ diff --git a/src/test/java/net/minecraftforge/debug/item/MapDataTest.java b/src/test/java/net/minecraftforge/debug/item/MapDataTest.java deleted file mode 100644 index 51734febaa..0000000000 --- a/src/test/java/net/minecraftforge/debug/item/MapDataTest.java +++ /dev/null @@ -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 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 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 - { - @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; - } - } - -} -*/ diff --git a/src/test/java/net/minecraftforge/debug/item/MendingRepairTest.java b/src/test/java/net/minecraftforge/debug/item/MendingRepairTest.java deleted file mode 100644 index 8b6370a3ea..0000000000 --- a/src/test/java/net/minecraftforge/debug/item/MendingRepairTest.java +++ /dev/null @@ -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 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 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; - } - } -}*/ diff --git a/src/test/java/net/minecraftforge/debug/item/NBTShareTagTest.java b/src/test/java/net/minecraftforge/debug/item/NBTShareTagTest.java deleted file mode 100644 index 5d9f4393ff..0000000000 --- a/src/test/java/net/minecraftforge/debug/item/NBTShareTagTest.java +++ /dev/null @@ -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 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 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 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; - } - } -} -*/ diff --git a/src/test/java/net/minecraftforge/debug/item/OnItemUseFirstTest.java b/src/test/java/net/minecraftforge/debug/item/OnItemUseFirstTest.java deleted file mode 100644 index f382c7eaa4..0000000000 --- a/src/test/java/net/minecraftforge/debug/item/OnItemUseFirstTest.java +++ /dev/null @@ -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 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 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 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 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()]; - } - } -}*/ diff --git a/src/test/java/net/minecraftforge/debug/item/PotionCurabilityTest.java b/src/test/java/net/minecraftforge/debug/item/PotionCurabilityTest.java deleted file mode 100644 index 505d07b0b5..0000000000 --- a/src/test/java/net/minecraftforge/debug/item/PotionCurabilityTest.java +++ /dev/null @@ -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 event) - { - if (!ENABLED) return; - event.getRegistry().register(new Medicine().setRegistryName(MODID, "medicine")); - } - - @net.minecraftforge.eventbus.api.SubscribeEvent - public static void registerPotions(RegistryEvent.Register event) - { - if (!ENABLED) return; - INCURABLE_POTION = new IncurablePotion().setRegistryName(MODID, "incurable_potion"); - event.getRegistry().register(INCURABLE_POTION); - } - - @SubscribeEvent - public static void registerPotionTypes(RegistryEvent.Register 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 getCurativeItems() - { - // By default, no PotionEffect of this Potion can be cured by anything - return new ArrayList(); - } - } - - 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); - } - } - } -} -*/ diff --git a/src/test/java/net/minecraftforge/debug/item/PotionShouldRenderTest.java b/src/test/java/net/minecraftforge/debug/item/PotionShouldRenderTest.java deleted file mode 100644 index e1c6706cff..0000000000 --- a/src/test/java/net/minecraftforge/debug/item/PotionShouldRenderTest.java +++ /dev/null @@ -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; - } - } -} -*/ diff --git a/src/test/java/net/minecraftforge/debug/item/ShieldTest.java b/src/test/java/net/minecraftforge/debug/item/ShieldTest.java deleted file mode 100644 index 14d74cb72c..0000000000 --- a/src/test/java/net/minecraftforge/debug/item/ShieldTest.java +++ /dev/null @@ -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 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 getItemAttributeModifiers(EntityEquipmentSlot slot) - { - Multimap 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")); - } -}*/ diff --git a/src/test/java/net/minecraftforge/debug/misc/EnumPlantTypeTest.java b/src/test/java/net/minecraftforge/debug/misc/EnumPlantTypeTest.java deleted file mode 100644 index 16e6bf401f..0000000000 --- a/src/test/java/net/minecraftforge/debug/misc/EnumPlantTypeTest.java +++ /dev/null @@ -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!"); - } - }); - } -} -*/ diff --git a/src/test/java/net/minecraftforge/debug/mod/CapabilityTest.java b/src/test/java/net/minecraftforge/debug/mod/CapabilityTest.java deleted file mode 100644 index b635a0d866..0000000000 --- a/src/test/java/net/minecraftforge/debug/mod/CapabilityTest.java +++ /dev/null @@ -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 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 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 implements ICapabilitySerializable, 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 getCapability(@Nonnull Capability 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 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(event.getObject())); - } - - @SubscribeEvent - public void onItemLoad(AttachCapabilitiesEvent event) - { - if (event.getObject().getItem() == Items.STICK) - { - event.addCapability(new ResourceLocation("forge.testcapmod:dummy_cap"), new Provider(event.getObject())); - } - } - - @SuppressWarnings("rawtypes") - @SubscribeEvent - public void attachEvent(AttachCapabilitiesEvent event) //Test Raw type gets everything still. - { - System.currentTimeMillis(); - } - - @SubscribeEvent - public void attachTileEntity(AttachCapabilitiesEvent event) - { - if (!(event.getObject() instanceof TileEntity)) - { - throw new IllegalArgumentException("Generic event handler failed! Expected Tile Entity got " + event.getObject()); - } - } - - @SubscribeEvent - public void attachVillage(AttachCapabilitiesEvent 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 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 - { - @Override - public NBTBase writeNBT(Capability capability, IExampleCapability instance, EnumFacing side) - { - return null; - } - - @Override - public void readNBT(Capability 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() - { - } - } -} -*/ diff --git a/src/test/java/net/minecraftforge/debug/mod/ClientLoadingExceptionTest.java b/src/test/java/net/minecraftforge/debug/mod/ClientLoadingExceptionTest.java deleted file mode 100644 index 20f4149c69..0000000000 --- a/src/test/java/net/minecraftforge/debug/mod/ClientLoadingExceptionTest.java +++ /dev/null @@ -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 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); - } - }; - } -} -*/ diff --git a/src/test/java/net/minecraftforge/debug/mod/ConfigAnnotationTest.java b/src/test/java/net/minecraftforge/debug/mod/ConfigAnnotationTest.java deleted file mode 100644 index da0d79c1ae..0000000000 --- a/src/test/java/net/minecraftforge/debug/mod/ConfigAnnotationTest.java +++ /dev/null @@ -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 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 theMap; - - @Name("regex(test]") - public static Map 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); - } - } - } -} -*/ diff --git a/src/test/java/net/minecraftforge/debug/mod/ObjectHolderAnnotationTest.java b/src/test/java/net/minecraftforge/debug/mod/ObjectHolderAnnotationTest.java deleted file mode 100644 index ef58f432db..0000000000 --- a/src/test/java/net/minecraftforge/debug/mod/ObjectHolderAnnotationTest.java +++ /dev/null @@ -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() - .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 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 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{} - - - 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 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; - } -} -*/ diff --git a/src/test/java/net/minecraftforge/debug/mod/PermissionTest.java b/src/test/java/net/minecraftforge/debug/mod/PermissionTest.java deleted file mode 100644 index 464310949a..0000000000 --- a/src/test/java/net/minecraftforge/debug/mod/PermissionTest.java +++ /dev/null @@ -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 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"); - } - } - } -} -*/ diff --git a/src/test/java/net/minecraftforge/debug/mod/RegistryOverrideTest.java b/src/test/java/net/minecraftforge/debug/mod/RegistryOverrideTest.java deleted file mode 100644 index c35d5bf8a8..0000000000 --- a/src/test/java/net/minecraftforge/debug/mod/RegistryOverrideTest.java +++ /dev/null @@ -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 event) - { - if (ENABLED) - { - event.getRegistry().register(new BlockReplacement()); - } - } - - @SubscribeEvent - public static void registerItems(RegistryEvent.Register 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 event) - { - if (ENABLED) - { - event.getRegistry().register(new PotionType().setRegistryName("minecraft:awkward")); - } - } - - @SubscribeEvent - public static void registerPotions(RegistryEvent.Register 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; - } - } -} -*/ diff --git a/src/test/java/net/minecraftforge/debug/mod/package-info.java b/src/test/java/net/minecraftforge/debug/mod/package-info.java deleted file mode 100644 index 2a927213d2..0000000000 --- a/src/test/java/net/minecraftforge/debug/mod/package-info.java +++ /dev/null @@ -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; diff --git a/src/test/java/net/minecraftforge/debug/network/BigNetworkMessageTest.java b/src/test/java/net/minecraftforge/debug/network/BigNetworkMessageTest.java deleted file mode 100644 index 40e15bc2d2..0000000000 --- a/src/test/java/net/minecraftforge/debug/network/BigNetworkMessageTest.java +++ /dev/null @@ -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); - } - } - } - } -} -*/ diff --git a/src/test/java/net/minecraftforge/debug/network/TrackingTargetTest.java b/src/test/java/net/minecraftforge/debug/network/TrackingTargetTest.java deleted file mode 100644 index 27a0b6749d..0000000000 --- a/src/test/java/net/minecraftforge/debug/network/TrackingTargetTest.java +++ /dev/null @@ -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 - { - @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 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 - { - @Override - public IMessage onMessage(TestEntityMessage message, MessageContext ctx) - { - LOGGER.info("Received tracking point test entity message"); - return null; - } - } -} -*/ diff --git a/src/test/java/net/minecraftforge/debug/network/package-info.java b/src/test/java/net/minecraftforge/debug/network/package-info.java deleted file mode 100644 index b06390aaed..0000000000 --- a/src/test/java/net/minecraftforge/debug/network/package-info.java +++ /dev/null @@ -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; diff --git a/src/test/java/net/minecraftforge/debug/util/ModNameTooltip.java b/src/test/java/net/minecraftforge/debug/util/ModNameTooltip.java deleted file mode 100644 index d6ade1a041..0000000000 --- a/src/test/java/net/minecraftforge/debug/util/ModNameTooltip.java +++ /dev/null @@ -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.util; - -import javax.annotation.Nullable; -import java.util.List; - -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.util.text.TextFormatting; -import net.minecraftforge.api.distmarker.Dist; -import net.minecraftforge.event.entity.player.ItemTooltipEvent; -import net.minecraftforge.fml.common.Loader; -import net.minecraftforge.fml.common.Mod; -import net.minecraftforge.fml.ModContainer; - -//@Mod(modid = "forgemodnametooltip", name = "ForgeModNameTooltip", version = "1.0", clientSideOnly = true) -//@Mod.EventBusSubscriber(Side.CLIENT) -public class ModNameTooltip -{ - @net.minecraftforge.eventbus.api.SubscribeEvent(priority = net.minecraftforge.eventbus.api.EventPriority.LOW) - public static void onToolTip(ItemTooltipEvent event) - { - ItemStack itemStack = event.getItemStack(); - String modName = getModName(itemStack); - if (modName != null) - { - List toolTip = event.getToolTip(); - toolTip.add(TextFormatting.BLUE.toString() + TextFormatting.ITALIC.toString() + modName); - } - } - - @Nullable - private static String getModName(ItemStack itemStack) - { - if (!itemStack.isEmpty()) - { - Item item = itemStack.getItem(); - String modId = item.getCreatorModId(itemStack); - ModContainer modContainer = Loader.instance().getIndexedModList().get(modId); - if (modContainer != null) - { - return modContainer.getName(); - } - } - return null; - } -} -*/ diff --git a/src/test/java/net/minecraftforge/debug/util/RotatingWrench.java b/src/test/java/net/minecraftforge/debug/util/RotatingWrench.java deleted file mode 100644 index 3fed13b6c2..0000000000 --- a/src/test/java/net/minecraftforge/debug/util/RotatingWrench.java +++ /dev/null @@ -1,107 +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.util; - -import net.minecraft.block.Block; -import net.minecraft.block.state.IBlockState; -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.item.Item; -import net.minecraft.item.ItemStack; -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.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; - -//@Mod(modid = RotatingWrench.modID, name = "Wrench Rotate Debug", version = "0.0.0", acceptableRemoteVersions = "*") -public class RotatingWrench -{ - public static final String modID = "wrenchrotatedebug"; - private static final ResourceLocation testWrenchName = new ResourceLocation(modID, "test_wrench"); - @ObjectHolder("test_wrench") - public static final Item TEST_WRENCH = null; - - - //@Mod.EventBusSubscriber(modid = modID) - public static class Registration - { - @net.minecraftforge.eventbus.api.SubscribeEvent - public static void registerItems(RegistryEvent.Register event) - { - event.getRegistry().register(new TestWrench().setRegistryName(testWrenchName)); - } - - @SubscribeEvent - public static void registerModels(ModelRegistryEvent event) - { - final ModelResourceLocation wrenchName = new ModelResourceLocation(testWrenchName, "inventory"); - ModelBakery.registerItemVariants(TEST_WRENCH, wrenchName); - ModelLoader.setCustomMeshDefinition(TEST_WRENCH, is -> wrenchName); - } - } - - public static class TestWrench extends Item - { - public TestWrench() - { - setCreativeTab(CreativeTabs.TOOLS); - setMaxStackSize(1); - setHarvestLevel("wrench", 0); - } - - @Override - public EnumActionResult onItemUse(EntityPlayer player, World worldIn, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) - { - ItemStack wrench = player.getHeldItem(hand); - if (player.canPlayerEdit(pos, facing, wrench) && worldIn.isBlockModifiable(player, pos)) - { - IBlockState blockState = worldIn.getBlockState(pos); - Block block = blockState.getBlock(); - if (block.rotateBlock(worldIn, pos, facing)) - { - player.swingArm(hand); - worldIn.notifyNeighborsOfStateChange(pos, block, false); - return EnumActionResult.SUCCESS; - } - } - return EnumActionResult.FAIL; - } - - @Override - public String getItemStackDisplayName(ItemStack stack) - { - return "Forge Test Wrench"; - } - } -} -*/ diff --git a/src/test/java/net/minecraftforge/debug/util/TextureDumper.java b/src/test/java/net/minecraftforge/debug/util/TextureDumper.java deleted file mode 100644 index bf43d8d2bc..0000000000 --- a/src/test/java/net/minecraftforge/debug/util/TextureDumper.java +++ /dev/null @@ -1,105 +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.util; - -import net.minecraft.client.renderer.texture.TextureMap; -import net.minecraftforge.client.event.TextureStitchEvent; -import net.minecraftforge.common.MinecraftForge; -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 org.lwjgl.BufferUtils; -import org.lwjgl.opengl.GL11; -import org.lwjgl.opengl.GL12; - -import javax.imageio.ImageIO; -import java.io.File; -import java.io.IOException; -import java.nio.IntBuffer; - -// TODO 1.13: implement without java.awt -//@Mod(modid = TextureDumper.MODID, name = "Forge Texture Atlas Dump", version = TextureDumper.VERSION, clientSideOnly = true) -public class TextureDumper -{ - public static final String MODID = "forge_texture_dump"; - public static final String VERSION = "1.0"; - - public static final boolean ENABLE = false; - private static Logger logger; - - @Mod.EventHandler - public void preInit(FMLPreInitializationEvent event) - { - if (ENABLE) - { - logger = event.getModLog(); - MinecraftForge.EVENT_BUS.register(this); - } - } - - @SubscribeEvent - public void postTextureStitch(TextureStitchEvent.Post e) throws Exception - { - TextureMap map = e.getMap(); - String name = map.getBasePath().replace('/', '_'); - int mip = map.getMipmapLevels(); - saveGlTexture(name, map.getGlTextureId(), mip); - } - - public static void saveGlTexture(String name, int textureId, int mipmapLevels) - { - GL11.glBindTexture(GL11.GL_TEXTURE_2D, textureId); - - GL11.glPixelStorei(GL11.GL_PACK_ALIGNMENT, 1); - GL11.glPixelStorei(GL11.GL_UNPACK_ALIGNMENT, 1); - - for (int level = 0; level <= mipmapLevels; level++) - { - int width = GL11.glGetTexLevelParameteri(GL11.GL_TEXTURE_2D, level, GL11.GL_TEXTURE_WIDTH); - int height = GL11.glGetTexLevelParameteri(GL11.GL_TEXTURE_2D, level, GL11.GL_TEXTURE_HEIGHT); - int size = width * height; - - BufferedImage bufferedimage = new BufferedImage(width, height, 2); - File output = new File("texture_atlas_dump_" + name + "_mipmap_" + level + ".png"); - - IntBuffer buffer = BufferUtils.createIntBuffer(size); - int[] data = new int[size]; - - GL11.glGetTexImage(GL11.GL_TEXTURE_2D, level, GL12.GL_BGRA, GL12.GL_UNSIGNED_INT_8_8_8_8_REV, buffer); - buffer.get(data); - bufferedimage.setRGB(0, 0, width, height, data, 0, width); - - try - { - ImageIO.write(bufferedimage, "png", output); - logger.info("Exported png to: {}", output.getAbsolutePath()); - } - catch (IOException ioexception) - { - logger.info("Unable to write: ", ioexception); - } - } - } -} -*/ diff --git a/src/test/java/net/minecraftforge/debug/util/package-info.java b/src/test/java/net/minecraftforge/debug/util/package-info.java deleted file mode 100644 index 0ef507241a..0000000000 --- a/src/test/java/net/minecraftforge/debug/util/package-info.java +++ /dev/null @@ -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.util; - -import javax.annotation.ParametersAreNonnullByDefault; -import mcp.MethodsReturnNonnullByDefault; diff --git a/src/test/java/net/minecraftforge/debug/village/MerchantTradeOffersEventTest.java b/src/test/java/net/minecraftforge/debug/village/MerchantTradeOffersEventTest.java deleted file mode 100644 index b2752c72a1..0000000000 --- a/src/test/java/net/minecraftforge/debug/village/MerchantTradeOffersEventTest.java +++ /dev/null @@ -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.village; - -import java.util.ListIterator; - -import net.minecraft.village.MerchantRecipe; -import net.minecraft.village.MerchantRecipeList; -import net.minecraftforge.common.MinecraftForge; -import net.minecraftforge.event.village.MerchantTradeOffersEvent; -import net.minecraftforge.fml.common.Mod; -import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; - -*/ -/** - * Tests {@link MerchantTradeOffersEvent}. When enabled, the item that the villager sells to - * the player will be maxed out in stack size. - *//* - -//@Mod(modid = MerchantTradeOffersEventTest.MODID, name = MerchantTradeOffersEventTest.NAME, version = "0.0.0", acceptableRemoteVersions = "*") -public class MerchantTradeOffersEventTest -{ - public static final String MODID = "merchanttradeofferseventtest"; - public static final String NAME = "Merchant Trade Offers Event Test"; - public static final boolean ENABLED = false; - - @Mod.EventHandler - public void preInit(FMLPreInitializationEvent event) - { - if (ENABLED) - { - MinecraftForge.EVENT_BUS.register(MerchantTradeOffersEventTest.class); - } - } - - @SubscribeEvent - public static void onGetRecipes(MerchantTradeOffersEvent event) - { - MerchantRecipeList list = event.getList(); - if (list != null) - { - ListIterator it = list.listIterator(); - while (it.hasNext()) - { - MerchantRecipe recipe = it.next(); - recipe.getItemToSell().setCount(recipe.getItemToSell().getMaxStackSize()); - } - } - } -} -*/ diff --git a/src/test/java/net/minecraftforge/debug/village/VillageSiegeEventTest.java b/src/test/java/net/minecraftforge/debug/village/VillageSiegeEventTest.java deleted file mode 100644 index 57a81f7cf9..0000000000 --- a/src/test/java/net/minecraftforge/debug/village/VillageSiegeEventTest.java +++ /dev/null @@ -1,71 +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.village; - -import java.util.Locale; - -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; - -import net.minecraft.init.Items; -import net.minecraftforge.common.MinecraftForge; -import net.minecraftforge.event.village.VillageSiegeEvent; -import net.minecraftforge.fml.common.Mod; -import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; - -*/ -/** - * Tests {@link VillageSiegeEvent}. When enabled, players holding a diamond sword in the mainhand - * slot are not counted in determining where the zombie siege occurs. - *//* - -//@Mod(modid = VillageSiegeEventTest.MODID, name = VillageSiegeEventTest.NAME, version = "0.0.0", acceptableRemoteVersions = "*") -public class VillageSiegeEventTest -{ - public static final String MODID = "villagesiegeeventtest"; - public static final String NAME = "Village Siege Event Test"; - public static final boolean ENABLED = false; - - public static final Logger LOG = LogManager.getLogger(MODID.toUpperCase(Locale.US)); - - @Mod.EventHandler - public void preInit(FMLPreInitializationEvent event) - { - if (ENABLED) - { - MinecraftForge.EVENT_BUS.register(VillageSiegeEventTest.class); - } - } - - @SubscribeEvent - public static void onVillageSiege(VillageSiegeEvent event) - { - if (!event.getWorld().isRemote && event.getPlayer().getHeldItemMainhand().getItem() == Items.DIAMOND_SWORD) - { - LOG.info("Village siege event for player "+event.getPlayer().getName()+" canceled"); - event.setCanceled(true); - } - } -} -*/ diff --git a/src/test/java/net/minecraftforge/debug/world/ChunkCapabilityTest.java b/src/test/java/net/minecraftforge/debug/world/ChunkCapabilityTest.java deleted file mode 100644 index ed5048d0a1..0000000000 --- a/src/test/java/net/minecraftforge/debug/world/ChunkCapabilityTest.java +++ /dev/null @@ -1,205 +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.world; - -import net.minecraft.init.Blocks; -import net.minecraft.init.Items; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTBase; -import net.minecraft.nbt.NBTTagInt; -import net.minecraft.util.EnumFacing; -import net.minecraft.util.ResourceLocation; -import net.minecraft.util.text.TextComponentString; -import net.minecraft.world.chunk.Chunk; -import net.minecraftforge.common.MinecraftForge; -import net.minecraftforge.common.capabilities.Capability; -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.FMLInitializationEvent; -import net.minecraftforge.eventbus.api.SubscribeEvent; - -import javax.annotation.Nonnull; -import javax.annotation.Nullable; - -*/ -/** - * Simple mod to test chunk capabilities. - * Use flint and steel to increase pollution in a chunk and saplings to decrease pollution in a chunk. - *//* - -//@Mod(modid = ChunkCapabilityTest.MODID, name = "Chunk Capability Test", version = "0.0.0", acceptableRemoteVersions = "*") -public class ChunkCapabilityTest -{ - public static final String MODID = "chunkcapabilitypollutiontest"; - public static final boolean ENABLE = false; - - public interface IPollution - { - int get(); - - void set(int value, boolean markDirty); - } - - public static class PollutionStorage implements Capability.IStorage - { - @Nullable - @Override - public NBTBase writeNBT(Capability capability, IPollution instance, EnumFacing side) { - return new NBTTagInt(instance.get()); - } - - @Override - public void readNBT(Capability capability, IPollution instance, EnumFacing side, NBTBase nbt) { - if (nbt instanceof NBTTagInt) - { - // The state is being loaded and not updated. We set the value silently to avoid unnecessary dirty chunks - instance.set(((NBTTagInt) nbt).getInt(), false); - } - } - } - - public static class DefaultPollution implements IPollution - { - private int value; - - @Override - public int get() { - return value; - } - - @Override - public void set(int value, boolean markDirty) { - this.value = value; - } - } - - */ -/** - * Marks the chunk as dirty when the value changes. - * Cannot be the default implementation because it requires a chunk in the constructor - *//* - - public static class SafePollution extends DefaultPollution - { - private final Chunk chunk; - - public SafePollution(Chunk chunk) - { - this.chunk = chunk; - } - - @Override - public void set(int value, boolean markDirty) { - super.set(value, markDirty); - if (markDirty) { - chunk.markDirty(); - } - } - } - - public static class PollutionProvider implements ICapabilitySerializable - { - private final IPollution pollution; - - public PollutionProvider(Chunk chunk) - { - pollution = new SafePollution(chunk); - } - - @Override - public NBTBase serializeNBT() { - return POLLUTION_CAPABILITY.getStorage().writeNBT(POLLUTION_CAPABILITY, pollution, null); - } - - @Override - public void deserializeNBT(NBTBase nbt) { - POLLUTION_CAPABILITY.getStorage().readNBT(POLLUTION_CAPABILITY, pollution, null, nbt); - } - - @Override - public boolean hasCapability(@Nonnull Capability capability, @Nullable EnumFacing facing) { - return capability == POLLUTION_CAPABILITY; - } - - @Nullable - @Override - public T getCapability(@Nonnull Capability capability, @Nullable EnumFacing facing) { - return capability == POLLUTION_CAPABILITY ? POLLUTION_CAPABILITY.cast(pollution) : null; - } - } - - public static class EventBusHandler - { - @net.minecraftforge.eventbus.api.SubscribeEvent - public void onAttachChunkCapabilities(AttachCapabilitiesEvent event) - { - event.addCapability(new ResourceLocation(MODID, "pollution"), new PollutionProvider(event.getObject())); - } - - @net.minecraftforge.eventbus.api.SubscribeEvent - public void onUseItem(PlayerInteractEvent.RightClickBlock event) - { - if (!event.getWorld().isRemote) { - ItemStack stack = event.getEntityPlayer().getHeldItem(event.getHand()); - int delta = 0; - if (stack.getItem() == Items.FLINT_AND_STEEL) - { - delta = 1; - } - else if (stack.getItem() == Item.getItemFromBlock(Blocks.SAPLING)) - { - delta = -1; - } - - if (delta != 0) - { - Chunk chunk = event.getWorld().getChunkFromBlockCoords(event.getPos()); - IPollution pollution = chunk.getCapability(POLLUTION_CAPABILITY, null); - pollution.set(pollution.get() + delta, true); - - event.getEntityPlayer().sendStatusMessage(new TextComponentString("Chunk pollution: " + pollution.get()), true); - } - } - } - } - - @CapabilityInject(IPollution.class) - public static final Capability POLLUTION_CAPABILITY = null; - - @Mod.EventHandler - public void init(FMLInitializationEvent event) - { - if (ENABLE) - { - CapabilityManager.INSTANCE.register(IPollution.class, new PollutionStorage(), DefaultPollution::new); - MinecraftForge.EVENT_BUS.register(new EventBusHandler()); - } - } - -} -*/ diff --git a/src/test/java/net/minecraftforge/debug/world/DecorateEventDebug.java b/src/test/java/net/minecraftforge/debug/world/DecorateEventDebug.java deleted file mode 100644 index e2ae114060..0000000000 --- a/src/test/java/net/minecraftforge/debug/world/DecorateEventDebug.java +++ /dev/null @@ -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.world; - -import net.minecraftforge.common.MinecraftForge; -import net.minecraftforge.event.terraingen.DecorateBiomeEvent; -import net.minecraftforge.fml.common.Mod; -import net.minecraftforge.fml.common.Mod.EventHandler; -import net.minecraftforge.fml.event.FMLInitializationEvent; -import net.minecraftforge.eventbus.api.Event.Result; -import net.minecraftforge.eventbus.api.SubscribeEvent; - -//@Mod(modid = DecorateEventDebug.MODID, name = DecorateEventDebug.NAME, version = DecorateEventDebug.VERSION, acceptableRemoteVersions = "*") -public class DecorateEventDebug -{ - - private static final boolean ENABLED = false; - public static final String MODID = "decorateeventdebug"; - public static final String NAME = "DecorateEventDebug"; - public static final String VERSION = "1.0.0"; - - @EventHandler - public void init(FMLInitializationEvent event) - { - if (ENABLED) - { - MinecraftForge.TERRAIN_GEN_BUS.register(this); - } - } - - @net.minecraftforge.eventbus.api.SubscribeEvent - public void decorateEvent(DecorateBiomeEvent.Decorate event) - { - event.setResult(Result.DENY); - } -} -*/ diff --git a/src/test/java/net/minecraftforge/debug/world/SpawnDimensionTest.java b/src/test/java/net/minecraftforge/debug/world/SpawnDimensionTest.java deleted file mode 100644 index cd8f78c880..0000000000 --- a/src/test/java/net/minecraftforge/debug/world/SpawnDimensionTest.java +++ /dev/null @@ -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.world; - -import net.minecraft.entity.Entity; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.util.math.BlockPos; -import net.minecraftforge.common.MinecraftForge; -import net.minecraftforge.event.entity.EntityJoinWorldEvent; -import net.minecraftforge.fml.common.Mod; -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; - -//@Mod(modid = SpawnDimensionTest.MODID, name = "CustomSpawnDimensionTest", version = "0.1", acceptableRemoteVersions = "*") -public class SpawnDimensionTest -{ - public static final String MODID = "customspawndimensiontest"; - - private static final boolean ENABLE = false; - - public SpawnDimensionTest() - { - if (ENABLE) - { - MinecraftForge.EVENT_BUS.register(this); - } - } - - @SubscribeEvent - public void enterDimension(EntityJoinWorldEvent event) - { - Entity e = event.getEntity(); - if (!(e instanceof EntityPlayer)) - { - return; - } - - BlockPos pos = e.getPosition(); - int dim = e.dimension; - - ((EntityPlayer) e).setSpawnDimension(dim); - ((EntityPlayer) e).setSpawnChunk(pos, true, dim); - } -} -*/ diff --git a/src/test/java/net/minecraftforge/debug/world/TileEntityLoadingTest.java b/src/test/java/net/minecraftforge/debug/world/TileEntityLoadingTest.java deleted file mode 100644 index c9ea4bc3b5..0000000000 --- a/src/test/java/net/minecraftforge/debug/world/TileEntityLoadingTest.java +++ /dev/null @@ -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.world; - -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.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.client.event.ModelRegistryEvent; -import net.minecraftforge.client.model.ModelLoader; -import net.minecraftforge.event.RegistryEvent; -import net.minecraftforge.fml.common.Mod; -import net.minecraftforge.fml.event.FMLPreInitializationEvent; -import net.minecraftforge.fml.common.registry.GameRegistry; -import net.minecraftforge.fml.common.registry.GameRegistry.ObjectHolder; -import net.minecraftforge.api.distmarker.Dist; - -import org.apache.logging.log4j.Logger; - -import javax.annotation.Nullable; -import java.util.Collections; - -//@Mod(modid = TileEntityLoadingTest.MODID, name = "TileEntity#onLoad() test mod", version = "1.0", acceptableRemoteVersions = "*") -public class TileEntityLoadingTest -{ - public static final boolean ENABLED = false; - static final String MODID = "te_loading_test"; - static final boolean DEBUG = false; - - private static Logger logger; - @ObjectHolder(TestBlock.NAME) - private 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 event) - { - if (!ENABLED) return; - event.getRegistry().register(new TestBlock()); - GameRegistry.registerTileEntity(TestTE.class, (new ResourceLocation(MODID, TestBlock.NAME)).toString()); - } - - @net.minecraftforge.eventbus.api.SubscribeEvent - public static void registerItems(RegistryEvent.Register event) - { - if (!ENABLED) return; - event.getRegistry().register(new ItemBlock(TEST_BLOCK).setRegistryName(TEST_BLOCK.getRegistryName())); - } - } - - //@Mod.EventBusSubscriber(value = Side.CLIENT, modid = MODID) - public static class ClientEventHandler - { - @net.minecraftforge.eventbus.api.SubscribeEvent - public static void registerModels(ModelRegistryEvent event) - { - if (!ENABLED) return; - ModelLoader.setCustomStateMapper(TEST_BLOCK, block -> Collections.emptyMap()); - ModelBakery.registerItemVariants(Item.getItemFromBlock(TEST_BLOCK)); - } - } - - @Mod.EventHandler - public static void preInit(FMLPreInitializationEvent event) - { - if (ENABLED) - logger = event.getModLog(); - } - - public static class TestBlock extends Block - { - static final String NAME = "test_block"; - - TestBlock() - { - super(Material.ANVIL); - setRegistryName(NAME); - setUnlocalizedName(MODID + "." + NAME); - setCreativeTab(CreativeTabs.BUILDING_BLOCKS); - } - - @Override - public boolean hasTileEntity(IBlockState state) - { - return true; - } - - @Nullable - @Override - public TileEntity createTileEntity(World world, IBlockState state) - { - return new TestTE(); - } - } - - public static class TestTE extends TileEntity - { - @Override - public void onLoad() - { - logger.info("World: {}, Pos: {}, State: {}", world, pos, world.getBlockState(pos)); - if (DEBUG) - { - logger.trace("Stack trace:", new Exception()); - } - } - } -} -*/ diff --git a/src/test/java/net/minecraftforge/debug/world/WorldCapabilityTest.java b/src/test/java/net/minecraftforge/debug/world/WorldCapabilityTest.java deleted file mode 100644 index f4f7b0e77c..0000000000 --- a/src/test/java/net/minecraftforge/debug/world/WorldCapabilityTest.java +++ /dev/null @@ -1,228 +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.world; - -import net.minecraft.nbt.NBTBase; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.util.EnumFacing; -import net.minecraft.util.ResourceLocation; -import net.minecraft.world.World; -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.fml.common.Mod; -import net.minecraftforge.fml.common.Mod.EventHandler; -import net.minecraftforge.fml.event.FMLInitializationEvent; -import net.minecraftforge.eventbus.api.SubscribeEvent; -import net.minecraftforge.event.TickEvent; - -import javax.annotation.Nonnull; -import javax.annotation.Nullable; - -*/ -/** - * Simple mod to test world capability, by adding timer logic and check for raining time. - *//* - -//@Mod(modid = WorldCapabilityTest.MODID, name = "World Periodic Rain Check Test", version = "0.0.0", acceptableRemoteVersions = "*") -public class WorldCapabilityTest -{ - public static final String MODID = "worldperiodicrainchecktest"; - static final boolean ENABLED = false; - - @CapabilityInject(IRainTimer.class) - public static final Capability TIMER_CAP = null; - - @EventHandler - public void init(FMLInitializationEvent event) - { - CapabilityManager.INSTANCE.register(IRainTimer.class, new TimerStorage(), DefaultTimer::new); - MinecraftForge.EVENT_BUS.register(new NormalEventHandler()); - } - - public static class NormalEventHandler - { - @SubscribeEvent - public void attatchTimer(AttachCapabilitiesEvent event) - { - if (!event.getObject().isRemote && !event.getObject().provider.isNether()) - { - event.addCapability(new ResourceLocation(MODID, "rainTimer"), new RainTimerProvider()); - } - } - - @SubscribeEvent - public void onTick(TickEvent.WorldTickEvent event) - { - if (!ENABLED || event.world.isRemote) - { - return; - } - - IRainTimer timer = event.world.getCapability(TIMER_CAP, null); - - if (timer == null) - { - return; - } - - if (event.phase == TickEvent.Phase.END) - { - timer.onTick(); - } - - if (event.phase == TickEvent.Phase.START) - { - if (event.world.isRaining()) - { - if (timer.getDuration() == 0) - { - timer.refreshTimer(1000, 0); - } - else if (timer.isTimerReachedDuration()) - { - event.world.provider.resetRainAndThunder(); - } - } - else - { - timer.refreshTimer(0, 0); - } - } - } - } - - public interface IRainTimer - { - public int getCurrentTime(); - - public int getDuration(); - - public void refreshTimer(int duration, int initial); - - public void resetTimer(); - - public boolean isTimerReachedDuration(); - - public void onTick(); - } - - public static class TimerStorage implements IStorage - { - @Override - public NBTBase writeNBT(Capability capability, IRainTimer instance, EnumFacing side) - { - NBTTagCompound compound = new NBTTagCompound(); - compound.setInteger("current", instance.getCurrentTime()); - compound.setInteger("duration", instance.getDuration()); - return compound; - } - - @Override - public void readNBT(Capability capability, IRainTimer instance, EnumFacing side, NBTBase nbt) - { - NBTTagCompound data = (NBTTagCompound) nbt; - instance.refreshTimer(data.getInteger("duration"), data.getInteger("current")); - } - } - - public static class DefaultTimer implements IRainTimer - { - private int duration, current; - - @Override - public int getCurrentTime() - { - return this.current; - } - - @Override - public int getDuration() - { - return this.duration; - } - - @Override - public void refreshTimer(int duration, int initial) - { - this.duration = duration; - this.current = initial; - } - - @Override - public void resetTimer() - { - this.current = 0; - } - - @Override - public boolean isTimerReachedDuration() - { - return this.current >= this.duration; - } - - @Override - public void onTick() - { - if (this.current < this.duration) - { - this.current++; - } - } - } - - public static class RainTimerProvider implements ICapabilitySerializable - { - private IRainTimer timer = TIMER_CAP.getDefaultInstance(); - - @Override - public boolean hasCapability(@Nonnull Capability capability, @Nullable EnumFacing facing) - { - return capability == TIMER_CAP; - } - - @Override - @Nullable - public T getCapability(@Nonnull Capability capability, @Nullable EnumFacing facing) - { - return capability == TIMER_CAP ? TIMER_CAP.cast(this.timer) : null; - } - - @Override - public NBTTagCompound serializeNBT() - { - return (NBTTagCompound) TIMER_CAP.writeNBT(this.timer, null); - } - - @Override - public void deserializeNBT(NBTTagCompound nbt) - { - TIMER_CAP.readNBT(this.timer, null, nbt); - } - } -} -*/ diff --git a/src/test/java/net/minecraftforge/debug/world/WorldProviderCanSleepAtTest.java b/src/test/java/net/minecraftforge/debug/world/WorldProviderCanSleepAtTest.java deleted file mode 100644 index 29776c4788..0000000000 --- a/src/test/java/net/minecraftforge/debug/world/WorldProviderCanSleepAtTest.java +++ /dev/null @@ -1,73 +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.world; - -import org.apache.logging.log4j.Logger; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.DimensionType; -import net.minecraft.world.WorldProvider; -import net.minecraftforge.common.DimensionManager; -import net.minecraftforge.fml.common.Mod; -import net.minecraftforge.fml.common.Mod.EventHandler; -import net.minecraftforge.fml.event.FMLPreInitializationEvent; - -//@Mod(modid = WorldProviderCanSleepAtTest.MODID, name = "Can Sleep At Test", version = "0.0.0", acceptableRemoteVersions = "*") -public class WorldProviderCanSleepAtTest -{ - public static final String MODID = "can_sleep_at_test"; - public static final boolean ENABLED = false; - public static DimensionType dimType = null; - public static int dimId; - private static Logger logger; - - @EventHandler - public void onPreInit(FMLPreInitializationEvent event) - { - if (ENABLED) - { - logger = event.getModLog(); - dimId = DimensionManager.getNextFreeDimId(); - dimType = DimensionType.register("CanSleepAtTest", "_cansleepattest", dimId, WorldProviderTest.class, false); - DimensionManager.registerDimension(dimId, dimType); - logger.info("Registered CanSleepAtTest dimension as DIM {}", dimId); - } - } - - public static class WorldProviderTest extends WorldProvider - { - @Override - public DimensionType getDimensionType() - { - return WorldProviderCanSleepAtTest.dimType; - } - - @Override - public WorldSleepResult canSleepAt(EntityPlayer player, BlockPos pos) - { - // Creates a 5x5 blocks wide grid of the different sleep results - return WorldSleepResult.values()[((pos.getX() / 5) + (pos.getZ() / 5)) % WorldSleepResult.values().length]; - } - } -} -*/ diff --git a/src/test/java/net/minecraftforge/fml/common/registry/BlockStateMappingsTest.java b/src/test/java/net/minecraftforge/fml/common/registry/BlockStateMappingsTest.java deleted file mode 100644 index c30942330d..0000000000 --- a/src/test/java/net/minecraftforge/fml/common/registry/BlockStateMappingsTest.java +++ /dev/null @@ -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.fml.common.registry; - -import net.minecraft.block.Block; -import net.minecraft.block.state.IBlockState; -import net.minecraft.init.Blocks; -import net.minecraft.init.Bootstrap; -import net.minecraftforge.fml.common.DummyModContainer; -import net.minecraftforge.fml.common.Loader; -import net.minecraftforge.registries.GameData; - -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.runner.RunWith; - -import static org.junit.Assert.assertEquals; - -*/ -/** - * Test block state mappings bidirectionality - *//* - -@RunWith(ForgeTestRunner.class) -public class BlockStateMappingsTest -{ - @BeforeClass - public static void setup() - { - System.setProperty("fml.queryResult", "confirm"); - System.setProperty("fml.doNotBackup", "true"); - Loader.instance(); - Bootstrap.register(); - Loader.instance().setupTestHarness(new DummyModContainer(new ModMetadata() - {{ - modId = "test"; - }})); - } - - @Test - public void testBlockStates() - { - // stems have a problem where the blockstate for meta 0 is not the same in the blockstate map and from block.getStateFromMeta - // This test asserts that the two values should be equivalent - // Specifically, in vanilla the state for meta 0 in the blockstatemap is facing=east,age=0 but the block says it's facing=up,age=0 - Block bl = Blocks.MELON_STEM; - int id = Block.getIdFromBlock(bl); - for (int meta = 0; meta < 8; meta++) - { - int realbsm = id << 4 | meta; // computed blockstateid for this meta - IBlockState realst = bl.getStateFromMeta(meta); // The state that the block assigns to this meta - int bsm = GameData.getBlockStateIDMap().get(realst); // The blockstateid for the meta's state - IBlockState foundst = GameData.getBlockStateIDMap().getByValue(realbsm); // The state that is stored for the computed blockstateid - assertEquals("Got computed blockstate ids that match", realbsm, bsm); - assertEquals("Got equal states", realst, foundst); - } - } - -} -*/ diff --git a/src/test/java/net/minecraftforge/fml/common/registry/DummyBlockReplacementTest.java b/src/test/java/net/minecraftforge/fml/common/registry/DummyBlockReplacementTest.java deleted file mode 100644 index 92b56cf348..0000000000 --- a/src/test/java/net/minecraftforge/fml/common/registry/DummyBlockReplacementTest.java +++ /dev/null @@ -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.fml.common.registry; - -import net.minecraft.block.Block; -import net.minecraft.block.BlockDirt; -import net.minecraft.init.Blocks; -import net.minecraft.init.Bootstrap; -import net.minecraft.util.ResourceLocation; -import net.minecraftforge.fml.common.DummyModContainer; -import net.minecraftforge.fml.common.Loader; -import net.minecraftforge.registries.ForgeRegistry; -import net.minecraftforge.registries.GameData; -import net.minecraftforge.registries.ObjectHolderRegistry; -import net.minecraftforge.registries.RegistryManager; - -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.runner.RunWith; - -import com.google.common.collect.Maps; - -import java.util.Map; -import java.util.Set; - -import static org.junit.Assert.*; - -*/ -/** - * Dummy block replacement test - *//* - -@RunWith(ForgeTestRunner.class) -public class DummyBlockReplacementTest -{ - private ResourceLocation myDirt = new ResourceLocation("test:dirt"); - private BlockDirt testDirtBlock = new BlockDirt() - { - - }; - - @BeforeClass - public static void setup() - { - System.setProperty("fml.queryResult", "confirm"); - System.setProperty("fml.doNotBackup", "true"); - Loader.instance(); - Bootstrap.register(); - Loader.instance().setupTestHarness(new DummyModContainer(new ModMetadata() - {{ - modId = "test"; - }})); - } - - @Test - public void testDummyBlockReplacement() - { - final Map snapshot = Maps.newHashMap(); - GameData.freezeData(); - ObjectHolderRegistry.INSTANCE.applyObjectHolders(); - - final ForgeRegistry blockRegistry = (ForgeRegistry)RegistryManager.ACTIVE.getRegistry(Block.class); - Block fnd = blockRegistry.getValue(myDirt); - - assertNotEquals("Didn't find my block", fnd, testDirtBlock); - assertEquals("Found a default air block", fnd, Blocks.AIR); - - // Insert a dummy reference to my dirt - snapshot.put(GameData.BLOCKS, new ForgeRegistry.Snapshot()); - snapshot.get(GameData.BLOCKS).ids.put(myDirt, 218); - GameData.injectSnapshot(snapshot, true, true); - ObjectHolderRegistry.INSTANCE.applyObjectHolders(); - - fnd = blockRegistry.getValue(myDirt); - assertNotEquals("Did not find my block", fnd, testDirtBlock); - assertTrue("Did not find a dummy air block", fnd.getClass().getName().endsWith("BlockDummyAir")); - final Set dummied = RegistryManager.ACTIVE.takeSnapshot(false).get(GameData.BLOCKS).dummied; - assertTrue("Did not find my block in the dummy list", dummied.contains(myDirt)); - - GameData.revertToFrozen(); - ObjectHolderRegistry.INSTANCE.applyObjectHolders(); - fnd = blockRegistry.getValue(myDirt); - assertNotEquals("Did not find my block", fnd, testDirtBlock); - assertEquals("Found a default air block", fnd, Blocks.AIR); - - ((ForgeRegistry)RegistryManager.ACTIVE.getRegistry(Block.class)).unfreeze(); - RegistryManager.ACTIVE.getRegistry(Block.class).register(testDirtBlock.setRegistryName(myDirt)); - fnd = blockRegistry.getValue(myDirt); - assertEquals("Found my block", fnd, testDirtBlock); - - // Add dummied entry in - snapshot.get(GameData.BLOCKS).dummied.add(myDirt); - // Loading locally - we should resuscitate our block - GameData.injectSnapshot(snapshot, true, true); - ObjectHolderRegistry.INSTANCE.applyObjectHolders(); - fnd = blockRegistry.getValue(myDirt); - assertEquals("Found my block", fnd, testDirtBlock); - GameData.revertToFrozen(); - - // Sent remotely, we should NOT resuscitate our block - GameData.injectSnapshot(snapshot, false, false); - ObjectHolderRegistry.INSTANCE.applyObjectHolders(); - fnd = blockRegistry.getValue(myDirt); - assertNotEquals("Did not find my block", fnd, testDirtBlock); - assertTrue("Found a dummy air block", fnd.getClass().getName().endsWith("BlockDummyAir")); - } -} -*/ diff --git a/src/test/java/net/minecraftforge/fml/common/registry/ForgeTestRunner.java b/src/test/java/net/minecraftforge/fml/common/registry/ForgeTestRunner.java deleted file mode 100644 index 05bdb540a4..0000000000 --- a/src/test/java/net/minecraftforge/fml/common/registry/ForgeTestRunner.java +++ /dev/null @@ -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.fml.common.registry; - -import com.google.common.collect.Sets; -import org.junit.runner.Description; -import org.junit.runner.Runner; -import org.junit.runner.notification.Failure; -import org.junit.runner.notification.RunNotifier; -import org.junit.runners.JUnit4; -import org.junit.runners.model.InitializationError; - -import java.net.URLClassLoader; -import java.util.Collections; -import java.util.Set; - -*/ -/** - * Uses {@code ResettingClassLoader} to load the test class. Minecraft and Forge - * classes are loaded using the separate class loader. - * - * Use of a separate class loader allows classes to be reloaded for each test - * class, which is handy when you're testing frameworks that make use of static - * members. - * - * The selective quarantining is required because if the test class and its - * 'children' are all loaded by a different class loader, then the {@code Test} - * annotations yield different {@code Class} instances. JUnit then thinks there - * are no runnable methods, because it looks them up by Class. - * - * This is a simplified copy of https://github.com/BinaryTweed/quarantining-test-runner - * tailored for Minecraft use. - * - *//* - -public class ForgeTestRunner extends Runner -{ - private final Object innerRunner; - private final Class innerRunnerClass; - - public ForgeTestRunner(Class testFileClass) throws InitializationError - { - Class delegateRunningTo = JUnit4.class; - - String testFileClassName = testFileClass.getName(); - String delegateRunningToClassName = delegateRunningTo.getName(); - - String[] allPatterns = new String[]{testFileClassName, delegateRunningToClassName}; - - ResettingClassLoader classLoader = new ResettingClassLoader(allPatterns); - - try - { - innerRunnerClass = classLoader.loadClass(delegateRunningToClassName); - Class testClass = classLoader.loadClass(testFileClassName); - innerRunner = innerRunnerClass.cast(innerRunnerClass.getConstructor(Class.class).newInstance(testClass)); - } - catch (Exception e) - { - throw new InitializationError(e); - } - } - - - @Override - public Description getDescription() - { - try - { - return (Description) innerRunnerClass.getMethod("getDescription").invoke(innerRunner); - } - catch (Exception e) - { - throw new RuntimeException("Could not get description", e); - } - } - - @Override - public void run(RunNotifier notifier) - { - try - { - System.setProperty("forge.disableVanillaGameData", "false"); - innerRunnerClass.getMethod("run", RunNotifier.class).invoke(innerRunner, notifier); - } - catch (Exception e) - { - notifier.fireTestFailure(new Failure(getDescription(), e)); - } - } - - */ -/** - * If a class name starts with any of the supplied patterns, it is loaded by - * this classloader; otherwise it is loaded by the parent classloader. - *//* - - private class ResettingClassLoader extends URLClassLoader - { - private final Set quarantinedClassNames; - - */ -/** - * @param quarantinedClassNames prefixes to match against when deciding how to load a class - *//* - - public ResettingClassLoader(String... quarantinedClassNames) - { - super(((URLClassLoader) getSystemClassLoader()).getURLs()); - - this.quarantinedClassNames = Sets.newHashSet(); - Collections.addAll(this.quarantinedClassNames, quarantinedClassNames); - Collections.addAll(this.quarantinedClassNames, "net.minecraft", "net.minecraftforge"); - } - - - */ -/** - * If a class name starts with any of the supplied patterns, it is loaded by - * this classloader; otherwise it is loaded by the parent classloader. - * - * @param name class to load - *//* - - @Override - public Class loadClass(String name) throws ClassNotFoundException - { - boolean quarantine = false; - - for (String quarantinedPattern : quarantinedClassNames) - { - if (name.startsWith(quarantinedPattern)) - { - quarantine = true; - break; - } - } - - if (quarantine) - { - try - { - return findClass(name); - } - catch (ClassNotFoundException e) - { - throw e; - } - } - - return super.loadClass(name); - } - } -} -*/ diff --git a/src/test/java/net/minecraftforge/fml/common/registry/FreezingTests.java b/src/test/java/net/minecraftforge/fml/common/registry/FreezingTests.java deleted file mode 100644 index 8e35d7c5f8..0000000000 --- a/src/test/java/net/minecraftforge/fml/common/registry/FreezingTests.java +++ /dev/null @@ -1,158 +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.fml.common.registry; - -import net.minecraft.block.Block; -import net.minecraft.item.Item; -import net.minecraft.util.ResourceLocation; -import net.minecraftforge.fml.common.Loader; -import net.minecraftforge.registries.ForgeRegistry; -import net.minecraftforge.registries.GameData; -import net.minecraftforge.registries.IForgeRegistry; -import net.minecraftforge.registries.IForgeRegistryEntry; -import net.minecraftforge.registries.RegistryBuilder; -import net.minecraftforge.registries.RegistryManager; - -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.runner.RunWith; - -import com.google.common.collect.Maps; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotEquals; - -import java.util.Map; - -*/ -/** - * Created by cpw on 04/07/16. - *//* - -@RunWith(ForgeTestRunner.class) -public class FreezingTests -{ - - private static RTest r1; - private static RTest r2; - private static RTest r3; - private static RTest r4; - private static RTest r5; - private static RTest r6; - private static Map ss; - - static class RTest extends IForgeRegistryEntry.Impl - { - public RTest(String name) - { - setRegistryName(name); - } - @Override - public String toString() - { - return this.getRegistryName().toString(); - } - } - - public static ResourceLocation resloc = new ResourceLocation("fmltest:test"); - - @BeforeClass - public static void setup() - { - Loader.instance(); - System.setProperty("fml.queryResult", "confirm"); - System.setProperty("fml.doNotBackup", "true"); - System.setProperty("forge.disableVanillaGameData", "true"); - - new RegistryBuilder().setName(resloc).setType(RTest.class).setIDRange(0, 255).create(); - new RegistryBuilder().setName(GameData.BLOCKS).setType(Block.class).setIDRange(0, 255).create(); - new RegistryBuilder().setName(GameData.ITEMS).setType(Item.class).setIDRange(0, 255).create(); - - r1 = new RTest("test1"); - r2 = new RTest("test2"); - r3 = new RTest("test3"); - r4 = new RTest("test4"); - r5 = new RTest("test5"); - r6 = new RTest("test6"); - - ss = Maps.newHashMap(); - ss.put(GameData.BLOCKS, new ForgeRegistry.Snapshot()); - ss.put(GameData.ITEMS, new ForgeRegistry.Snapshot()); - - RegistryManager.ACTIVE.getRegistry(RTest.class).register(r1); - RegistryManager.ACTIVE.getRegistry(RTest.class).register(r2); - RegistryManager.ACTIVE.getRegistry(RTest.class).register(r3); - RegistryManager.ACTIVE.getRegistry(RTest.class).register(r4); - ss.put(resloc, ((ForgeRegistry)RegistryManager.ACTIVE.getRegistry(RTest.class)).makeSnapshot()); - - RegistryManager.ACTIVE.clean(); - RegistryManager.FROZEN.clean(); - new RegistryBuilder().setName(resloc).setType(RTest.class).setIDRange(0, 255).create(); - new RegistryBuilder().setName(GameData.BLOCKS).setType(Block.class).setIDRange(0, 255).create(); - new RegistryBuilder().setName(GameData.ITEMS).setType(Item.class).setIDRange(0, 255).create(); - } - - @Test - public void testFreezeCycle() - { - ResourceLocation name = new ResourceLocation("test3"); - ForgeRegistry active = (ForgeRegistry)RegistryManager.ACTIVE.getRegistry(RTest.class); - active.register(r6); - active.register(r5); - active.register(r4); - active.register(r3); - - int r3id = active.getID(r3); - GameData.freezeData(); - - //Frozen data should be the same, as there are no replacement - ForgeRegistry frozen = (ForgeRegistry)RegistryManager.ACTIVE.getRegistry(RTest.class); - assertEquals("Frozen object not the same", r3, frozen.getValue(name)); - assertEquals("Active object not the same", r3, active.getValue(name)); - - // r3 is in the snapshot, so the ID SHOULD change to whats in the snapshot. - GameData.injectSnapshot(ss, false, true); //Unlike the old system we die on missing mappings for custom registries. So we need to tell it to continue loading as if we're local - assertNotEquals("IDs match", r3id, active.getID(r3)); - assertEquals("Frozen object not the same", r3, frozen.getValue(name)); - assertEquals("Active object not the same", r3, active.getValue(name)); - - // Frozen has the original ID - GameData.revertToFrozen(); - assertEquals("IDs don't match", r3id, active.getID(r3)); - assertEquals("Frozen object not the same", r3, frozen.getValue(name)); - assertEquals("Active object not the same", r3, active.getValue(name)); - - // Make sure we have snapshot ID again - GameData.injectSnapshot(ss, true, true); - assertNotEquals("IDs match", r3id, active.getID(r3)); - assertEquals("Frozen object not the same", r3, frozen.getValue(name)); - assertEquals("Active object not the same", r3, active.getValue(name)); - - //And back to the frozen ID - GameData.revertToFrozen(); - assertEquals("IDs don't match", r3id, active.getID(r3)); - assertEquals("Frozen object not the same", r3, frozen.getValue(name)); - assertEquals("Active object not the same", r3, active.getValue(name)); - } -} -*/ diff --git a/src/test/java/net/minecraftforge/fml/common/registry/ItemBlockSubstitutionRemoveRestoreTest.java b/src/test/java/net/minecraftforge/fml/common/registry/ItemBlockSubstitutionRemoveRestoreTest.java deleted file mode 100644 index 105dfeee03..0000000000 --- a/src/test/java/net/minecraftforge/fml/common/registry/ItemBlockSubstitutionRemoveRestoreTest.java +++ /dev/null @@ -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.fml.common.registry; - -import net.minecraft.block.BlockDirt; -import net.minecraft.init.Blocks; -import net.minecraft.init.Bootstrap; -import net.minecraft.item.Item; -import net.minecraft.item.ItemBlock; -import net.minecraft.item.ItemMultiTexture; -import net.minecraft.item.ItemStack; -import net.minecraft.util.ResourceLocation; -import net.minecraftforge.fml.common.DummyModContainer; -import net.minecraftforge.fml.common.Loader; -import net.minecraftforge.registries.ForgeRegistry; -import net.minecraftforge.registries.GameData; -import net.minecraftforge.registries.ObjectHolderRegistry; -import net.minecraftforge.registries.RegistryManager; - -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.runner.RunWith; - -import javax.annotation.Nonnull; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotEquals; - -*/ -/** - * Substitution test harness - tests that substitutions behave correctly - *//* - -@RunWith(ForgeTestRunner.class) -public class ItemBlockSubstitutionRemoveRestoreTest -{ - private ResourceLocation myDirt = new ResourceLocation("minecraft:dirt"); - - private static class ItemMyDirt extends ItemMultiTexture - { - public ItemMyDirt() - { - super(Blocks.DIRT, Blocks.DIRT, new Mapper() - { - @Nonnull - public String apply(@Nonnull ItemStack p_apply_1_) - { - return BlockDirt.DirtType.byMetadata(p_apply_1_.getMetadata()).getUnlocalizedName(); - } - }); - } - } - - private static ItemMyDirt myDirtInstance; - private static Item originalDirt; - - @BeforeClass - public static void setup() - { - Loader.instance(); - Bootstrap.register(); - myDirtInstance = new ItemMyDirt(); - Loader.instance().setupTestHarness(new DummyModContainer(new ModMetadata() - {{ - modId = "test"; - }})); - originalDirt = new ItemStack(Blocks.DIRT).getItem(); - } - - @Test - public void testSubstitutionRemovalAndRestore() throws Exception - { - RegistryManager.ACTIVE.getRegistry(Item.class).register(myDirtInstance.setRegistryName(myDirt)); - GameData.freezeData(); - ObjectHolderRegistry.INSTANCE.applyObjectHolders(); - - final ForgeRegistry itemRegistry = (ForgeRegistry)RegistryManager.ACTIVE.getRegistry(Item.class); - - // TEST 1: Does my substitute take effect? The substitute should be found in the registry - ItemBlock dirtitem = (ItemBlock) itemRegistry.getValue(myDirt); - assertEquals("ItemBlock points at my block", myDirtInstance, dirtitem); - - // TEST 2: Does the substitute get removed when told by remote operation? The substitute should NOT be found in the registry - */ -/* Why should it not be found? Substitutions are no longer special cases - Map snapshot = RegistryManager.ACTIVE.takeSnapshot(false); - snapshot.get(GameData.ITEMS).substitutions.clear(); - GameData.injectSnapshot(snapshot, false, false); - ObjectHolderRegistry.INSTANCE.applyObjectHolders(); - - dirtitem = (ItemBlock) itemRegistry.getValue(myDirt); - assertEquals("ItemBlock points at vanilla block", originalDirt, dirtitem); - assertNotEquals("ItemBlock points at my block", myDirtInstance, dirtitem); - *//* - - - // TEST 3: Does the substitute get restored when reverting to frozen state? The substitute should be found in the registry again - GameData.revertToFrozen(); - ObjectHolderRegistry.INSTANCE.applyObjectHolders(); - dirtitem = (ItemBlock) itemRegistry.getValue(myDirt); - assertEquals("ItemBlock points at my block", myDirtInstance, dirtitem); - } -} -*/ diff --git a/src/test/java/net/minecraftforge/fml/common/registry/RegistryTestSuite.java b/src/test/java/net/minecraftforge/fml/common/registry/RegistryTestSuite.java deleted file mode 100644 index a00805f660..0000000000 --- a/src/test/java/net/minecraftforge/fml/common/registry/RegistryTestSuite.java +++ /dev/null @@ -1,38 +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.fml.common.registry; - -import org.junit.runner.RunWith; -import org.junit.runners.Suite; - -*/ -/** - * Run the full suite of tests - *//* - -@RunWith(Suite.class) -@Suite.SuiteClasses({VanillaRegistryTests.class, FreezingTests.class, SubstitutionRemoveRestoreTest.class, SubstitutionInjectionTest.class, DummyBlockReplacementTest.class, BlockStateMappingsTest.class}) -public class RegistryTestSuite -{ -} -*/ diff --git a/src/test/java/net/minecraftforge/fml/common/registry/SubstitutionInjectionTest.java b/src/test/java/net/minecraftforge/fml/common/registry/SubstitutionInjectionTest.java deleted file mode 100644 index 93935a2be4..0000000000 --- a/src/test/java/net/minecraftforge/fml/common/registry/SubstitutionInjectionTest.java +++ /dev/null @@ -1,169 +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.fml.common.registry; - -import net.minecraft.block.Block; -import net.minecraft.block.BlockDirt; -import net.minecraft.init.Blocks; -import net.minecraft.init.Bootstrap; -import net.minecraft.item.Item; -import net.minecraft.item.ItemBlock; -import net.minecraft.stats.StatList; -import net.minecraft.util.ResourceLocation; -import net.minecraftforge.fml.common.DummyModContainer; -import net.minecraftforge.fml.common.Loader; -import net.minecraftforge.registries.ForgeRegistry; -import net.minecraftforge.registries.GameData; -import net.minecraftforge.registries.ObjectHolderRegistry; -import net.minecraftforge.registries.RegistryManager; - -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.runner.RunWith; - -import javax.annotation.Nonnull; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.fail; - -import java.util.Map; - -*/ -/** - * Substitution test harness - tests that substitutions behave correctly - *//* - -@RunWith(ForgeTestRunner.class) -public class SubstitutionInjectionTest -{ - private ResourceLocation MC_DIRT = new ResourceLocation("minecraft:dirt"); - private Block toSub = (new BlockDirt() - { - @Override - @Nonnull - public String toString() - { - return "SUB" + super.toString() + "SUB"; - } - }).setRegistryName(MC_DIRT); - - @BeforeClass - public static void setup() - { - Loader.instance(); - Bootstrap.register(); - Loader.instance().setupTestHarness(new DummyModContainer(new ModMetadata() - {{ - modId = "test"; - }})); - } - - @Test - public void testSubstitutionInjection() throws Exception - { - final ForgeRegistry blockRegistry = (ForgeRegistry)RegistryManager.ACTIVE.getRegistry(Block.class); - final ForgeRegistry itemRegistry = (ForgeRegistry)RegistryManager.ACTIVE.getRegistry(Item.class); - - // Capture snapshot prior to registering the substitution - this is a world state "pre-substitute" - final Map snapshot = RegistryManager.ACTIVE.takeSnapshot(false); - - Block fnd = blockRegistry.getValue(MC_DIRT); - Block vanilDirt = Blocks.DIRT; - Block currDirt = Blocks.DIRT; - // TEST 0: Verify that input state is correct - assertEquals("Got vanilla dirt ", currDirt, fnd); - - // TEST 0a: Validate that the ItemBlock for Dirt points at vanilla dirt - ItemBlock dirtitem = (ItemBlock) itemRegistry.getValue(MC_DIRT); - assertEquals("ItemBlock points at my block", currDirt, dirtitem.getBlock()); - - blockRegistry.register(toSub); //Register a new object, with the same vanilla name, Should cause the item to be replaced - GameData.freezeData(); - ObjectHolderRegistry.INSTANCE.applyObjectHolders(); - // This should not throw an exception - try - { - StatList.reinit(); - } - catch (Exception e) - { - fail("Caught exception"); - } - - // TEST 1: Does my substitute take effect? The substitute should be found in the registry - fnd = blockRegistry.getValue(MC_DIRT); - currDirt = Blocks.DIRT; - assertEquals("Got vanilla dirt - Blocks", toSub, currDirt); - assertEquals("ObjectHolder didn't apply - Blocks and registry", currDirt, fnd); - assertEquals("Got vanilla dirt - registry", toSub, fnd); - - // TEST 1a: Validate that the ItemBlock for Dirt now points at my dirt - dirtitem = (ItemBlock) itemRegistry.getValue(MC_DIRT); - assertEquals("ItemBlock points at vanilla block", toSub, dirtitem.getBlock()); - - // TEST 2: Is the substitute still in the registry? The snapshot was taken before the substitute was added so it should NOT exist - GameData.injectSnapshot(snapshot, false, true); - ObjectHolderRegistry.INSTANCE.applyObjectHolders(); - fnd = blockRegistry.getValue(MC_DIRT); - currDirt = Blocks.DIRT; - assertEquals("Got my dirt substitute - Blocks", vanilDirt, currDirt); - assertEquals("ObjectHolder didn't apply - Blocks and registry", currDirt, fnd); - assertEquals("Got my dirt substitute - registry", vanilDirt, fnd); - dirtitem = (ItemBlock) itemRegistry.getValue(MC_DIRT); - assertEquals("ItemBlock points at my block", vanilDirt, dirtitem.getBlock()); - - // TEST 3: Does the substitute get restored when reverting to frozen state? The substitute should be found in the registry again - GameData.revertToFrozen(); - ObjectHolderRegistry.INSTANCE.applyObjectHolders(); - fnd = blockRegistry.getValue(MC_DIRT); - currDirt = Blocks.DIRT; - assertEquals("Got vanilla dirt - Blocks", toSub, currDirt); - assertEquals("ObjectHolder didn't apply - Blocks and registry", currDirt, fnd); - assertEquals("Got vanilla dirt - registry", toSub, fnd); - dirtitem = (ItemBlock) itemRegistry.getValue(MC_DIRT); - assertEquals("ItemBlock points at vanilla block", toSub, dirtitem.getBlock()); - - // TEST 3: Is the substitute still in the registry? The snapshot was taken before the substitute, but we inject frozen data, so we SHOULD have the sub. - GameData.injectSnapshot(snapshot, true, true); - ObjectHolderRegistry.INSTANCE.applyObjectHolders(); - fnd = blockRegistry.getValue(MC_DIRT); - currDirt = Blocks.DIRT; - assertEquals("Got vanilla dirt - Blocks", toSub, currDirt); - assertEquals("ObjectHolder didn't apply - Blocks and registry", currDirt, fnd); - assertEquals("Got vanilla dirt - registry", toSub, fnd); - dirtitem = (ItemBlock) itemRegistry.getValue(MC_DIRT); - assertEquals("ItemBlock points at vanilla block", toSub, dirtitem.getBlock()); - - // TEST 3 repeat: Does the substitute get restored when reverting to frozen state? The substitute should be found in the registry again - GameData.revertToFrozen(); - ObjectHolderRegistry.INSTANCE.applyObjectHolders(); - fnd = blockRegistry.getValue(MC_DIRT); - currDirt = Blocks.DIRT; - assertEquals("Got vanilla dirt - Blocks", toSub, currDirt); - assertEquals("ObjectHolder didn't apply - Blocks and registry", currDirt, fnd); - assertEquals("Got vanilla dirt - registry", toSub, fnd); - dirtitem = (ItemBlock) itemRegistry.getValue(MC_DIRT); - assertEquals("ItemBlock points at vanilla block", toSub, dirtitem.getBlock()); - } -} -*/ diff --git a/src/test/java/net/minecraftforge/fml/common/registry/SubstitutionRemoveRestoreTest.java b/src/test/java/net/minecraftforge/fml/common/registry/SubstitutionRemoveRestoreTest.java deleted file mode 100644 index a5a59a2106..0000000000 --- a/src/test/java/net/minecraftforge/fml/common/registry/SubstitutionRemoveRestoreTest.java +++ /dev/null @@ -1,116 +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.fml.common.registry; - -import net.minecraft.block.Block; -import net.minecraft.block.BlockDirt; -import net.minecraft.init.Bootstrap; -import net.minecraft.util.ResourceLocation; -import net.minecraftforge.fml.common.DummyModContainer; -import net.minecraftforge.fml.common.Loader; - -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.runner.RunWith; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotEquals; - -*/ -/** - * Substitution test harness - tests that substitutions behave correctly - *//* - -@RunWith(ForgeTestRunner.class) -public class SubstitutionRemoveRestoreTest -{ - private ResourceLocation MC_DIRT = new ResourceLocation("minecraft:dirt"); - private Block toSub = (new BlockDirt(){}).setRegistryName(MC_DIRT); - - @BeforeClass - public static void setup() - { - Loader.instance(); - Bootstrap.register(); - Loader.instance().setupTestHarness(new DummyModContainer(new ModMetadata() - {{ - modId = "test"; - }})); - } - - @Test - public void testSubstitutionRemovalAndRestore() throws Exception - { - */ -/* TODO: Figure this one out, We dont prevent the client from loading subs when the server says not to.. - * Why should we as long as the item is on both sides we should be fine. It's on the modder to make sure they are compatible. - * - final ForgeRegistry blockRegistry = (ForgeRegistry)RegistryManager.ACTIVE.getRegistry(Block.class); - final ForgeRegistry itemRegistry = (ForgeRegistry)RegistryManager.ACTIVE.getRegistry(Item.class); - Block vanilla = blockRegistry.getValue(MC_DIRT); - blockRegistry.register(toSub); - - GameData.freezeData(); - ObjectHolderRegistry.INSTANCE.applyObjectHolders(); - - - // TEST 1: Does my substitute take effect? The substitute should be found in the registry - Block fnd = blockRegistry.getValue(MC_DIRT); - Block currDirt = Blocks.DIRT; - assertEquals("Got Vanilla Dirt - Blocks", toSub, currDirt); - assertEquals("ObjectHolder didn't apply - Blocks and registry", currDirt, fnd); - assertEquals("Got Vanilla Dirt - registry", toSub, fnd); - ItemBlock dirtitem = (ItemBlock)itemRegistry.getValue(MC_DIRT); - assertEquals("ItemBlock points at my block", toSub, dirtitem.getBlock()); - - // TEST 2: Does the substitute get removed when told by remote operation? The substitute should NOT be found in the registry - final Map snapshot = RegistryManager.ACTIVE.takeSnapshot(false); - snapshot.entries.get(PersistentRegistryManager.BLOCKS).substitutions.clear(); - PersistentRegistryManager.injectSnapshot(snapshot, false, false); - ObjectHolderRegistry.INSTANCE.applyObjectHolders(); - fnd = blockRegistry.getValue(MC_DIRT); - currDirt = Blocks.DIRT; - assertNotEquals("Got my dirt substitute - Blocks", toSub, currDirt); - assertEquals("Got my dirt substitute - Blocks and registry", currDirt, fnd); - assertNotEquals("Got my dirt substitute - registry", toSub, fnd); - - dirtitem = (ItemBlock) itemRegistry.getValue(MC_DIRT); - assertEquals("ItemBlock points at vanilla block", currDirt, dirtitem.block); - assertNotEquals("ItemBlock points at my block", toSub, dirtitem.block); - - // TEST 3: Does the substitute get restored when reverting to frozen state? The substitute should be found in the registry again - PersistentRegistryManager.revertToFrozen(); - ObjectHolderRegistry.INSTANCE.applyObjectHolders(); - fnd = blockRegistry.getValue(MC_DIRT); - currDirt = Blocks.DIRT; - assertEquals("Got my dirt substitute - Blocks", toSub, currDirt); - assertEquals("Got my dirt substitute - Blocks and registry", currDirt, fnd); - assertEquals("Got my dirt substitute - registry", toSub, fnd); - - dirtitem = (ItemBlock) itemRegistry.getValue(MC_DIRT); - assertEquals("ItemBlock points at my block", toSub, dirtitem.block); - *//* - - } -} -*/ diff --git a/src/test/java/net/minecraftforge/fml/common/registry/VanillaRegistryTests.java b/src/test/java/net/minecraftforge/fml/common/registry/VanillaRegistryTests.java deleted file mode 100644 index 712a7bcdd2..0000000000 --- a/src/test/java/net/minecraftforge/fml/common/registry/VanillaRegistryTests.java +++ /dev/null @@ -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.fml.common.registry; - -import net.minecraft.block.Block; -import net.minecraft.block.material.Material; -import net.minecraft.init.Blocks; -import net.minecraft.init.Bootstrap; -import net.minecraft.init.Items; -import net.minecraft.item.Item; -import net.minecraft.util.ResourceLocation; -import net.minecraftforge.fml.common.Loader; -import net.minecraftforge.registries.ForgeRegistry; -import net.minecraftforge.registries.IForgeRegistry; -import net.minecraftforge.registries.RegistryManager; - -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.runner.RunWith; - -import static org.junit.Assert.*; - -import java.lang.reflect.Field; - -*/ -/** - * Vanilla registry tests - *//* - -@RunWith(ForgeTestRunner.class) -public class VanillaRegistryTests -{ - @BeforeClass - public static void setupHarness() - { - Loader.instance(); - Bootstrap.register(); - } - - @Test - public void testSetup() - { - // All the blocks loaded - assertEquals("We have all the blocks via GameData", 254, Block.REGISTRY.getKeys().size()); - - // All the items loaded - assertEquals("We have all the items via GameData", 411, Item.REGISTRY.getKeys().size()); - - // Our lookups find the same stuff vanilla sees - final IForgeRegistry blocks = RegistryManager.ACTIVE.getRegistry(Block.class); - assertEquals("We have a different block registry then vanilla", blocks, getDelegate(Block.REGISTRY)); - - // We can look up stuff through our APIs - Block bl = blocks.getValue(new ResourceLocation("minecraft:air")); - assertEquals("We got air when we asked for it", Blocks.AIR, bl); - - // Default values work - Block blch = blocks.getValue(new ResourceLocation("minecraft:cheese")); - assertEquals("We got air when we asked for cheese", Blocks.AIR, blch); - - // Our lookups find the same stuff vanilla sees - final IForgeRegistry items = RegistryManager.ACTIVE.getRegistry(Item.class); - assertEquals("We have a different item registry then vanilla", items, getDelegate(Item.REGISTRY)); - - // We can look up stuff through our APIs - Item it = items.getValue(new ResourceLocation("minecraft:bed")); - assertEquals("We got a bed item when we asked for it", Items.BED, it); - - // We find nothing for a non-defaulted registry - Item none = items.getValue(new ResourceLocation("minecraft:cheese")); - assertEquals("We got nothing (items) when we asked for cheese", null, none); - } - - private Object getDelegate(Object obj) - { - try - { - Field f = obj.getClass().getDeclaredField("delegate"); - f.setAccessible(true); - return f.get(obj); - } - catch (Exception e) - { - throw new RuntimeException(e); - } - } - - @Test - public void testRegistration() - { - final IForgeRegistry blocks = RegistryManager.ACTIVE.getRegistry(Block.class); - Block myBlock = (new Block(Material.CAKE){}).setRegistryName(new ResourceLocation("minecraft:testy")); - blocks.register(myBlock); - assertNotNull("Registered my block", myBlock); - - // Our lookups find the same stuff vanilla sees - assertEquals("We have a different block registry then vanilla", blocks, getDelegate(Block.REGISTRY)); - - Block found = blocks.getValue(new ResourceLocation("minecraft:testy")); - assertEquals("Registry lookup works", myBlock, found); - } - - @Test - public void testRegistryStates() - { - final ForgeRegistry blockVanilla = (ForgeRegistry)RegistryManager.VANILLA.getRegistry(Block.class); - final ForgeRegistry blockActive = (ForgeRegistry)RegistryManager.ACTIVE.getRegistry(Block.class); - - assertNotEquals("Registry states are distinct", blockActive, blockVanilla); - - final Block stoneActive = blockActive.getValue(new ResourceLocation("minecraft:stone")); - final Block stoneVanilla = blockVanilla.getValue(new ResourceLocation("minecraft:stone")); - - assertEquals("Stone from active and vanilla are the same", stoneActive, stoneVanilla); - - int activeId = blockActive.getID(stoneActive); - int vanillaId = blockVanilla.getID(stoneVanilla); - - assertEquals("Stone has correct id", 1, activeId); - assertEquals("Stone has correct id", 1, vanillaId); - } - - -} -*/ diff --git a/src/test/java/net/minecraftforge/fml/debug/FaultyCoreMod.java b/src/test/java/net/minecraftforge/fml/debug/FaultyCoreMod.java deleted file mode 100644 index 7880b9e882..0000000000 --- a/src/test/java/net/minecraftforge/fml/debug/FaultyCoreMod.java +++ /dev/null @@ -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.fml.debug; - -import net.minecraft.launchwrapper.IClassTransformer; - -import java.util.Map; - -public class FaultyCoreMod implements IFMLLoadingPlugin -{ - public static boolean enabled = false; - - @Override - public String[] getASMTransformerClass() - { - return new String[]{FaultyTransformer.class.getName()}; - } - - @Override - public String getModContainerClass() - { - return null; - } - - @Override - public String getSetupClass() - { - return null; - } - - @Override - public void injectData(Map data) - { - } - - @Override - public String getAccessTransformerClass() - { - return null; - } - - public static class FaultyTransformer implements IClassTransformer - { - - @Override - public byte[] transform(String name, String transformedName, byte[] basicClass) - { - if (enabled && name.equals("net.minecraft.client.gui.GuiMainMenu")) - { - throw new RuntimeException("Faulty transformer test exception"); - } - return basicClass; - } - } -} -*/ diff --git a/src/test/java/net/minecraftforge/fml/test/ForgeNetworkTestMod.java b/src/test/java/net/minecraftforge/fml/test/ForgeNetworkTestMod.java deleted file mode 100644 index 63af0e5cb9..0000000000 --- a/src/test/java/net/minecraftforge/fml/test/ForgeNetworkTestMod.java +++ /dev/null @@ -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.fml.test; - -import io.netty.buffer.Unpooled; -import net.minecraft.entity.player.EntityPlayerMP; -import net.minecraft.network.NetHandlerPlayServer; -import net.minecraft.network.PacketBuffer; -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.fml.common.gameevent.PlayerEvent.PlayerLoggedInEvent; -import net.minecraftforge.fml.common.network.FMLEventChannel; -import net.minecraftforge.fml.common.network.FMLNetworkEvent; -import net.minecraftforge.fml.common.network.NetworkRegistry; -import net.minecraftforge.fml.common.network.internal.FMLProxyPacket; -import net.minecraftforge.api.distmarker.Dist; - -//@Mod(modid = ForgeNetworkTestMod.MOD_ID, name = ForgeNetworkTestMod.MOD_ID, version = "1.0", acceptableRemoteVersions = "*") -public class ForgeNetworkTestMod -{ - private static final boolean ENABLED = false; - public static final String MOD_ID = "forge_network_test"; - - private FMLEventChannel channel; - private Logger logger; - - @EventHandler - public void onPreInit(FMLPreInitializationEvent e) - { - if (ENABLED) - { - MinecraftForge.EVENT_BUS.register(this); - channel = NetworkRegistry.INSTANCE.newEventDrivenChannel(MOD_ID); - channel.register(this); - logger = e.getModLog(); - } - } - - @SubscribeEvent - public void onConnectionFromClient(FMLNetworkEvent.ServerConnectionFromClientEvent event) - { - if (channel != null && event.getHandler() instanceof NetHandlerPlayServer) - { - PacketBuffer buffer = new PacketBuffer(Unpooled.buffer()); - buffer.writeByte(0); - channel.sendTo(new FMLProxyPacket(buffer, MOD_ID), ((NetHandlerPlayServer) event.getHandler()).player); - } - } - - @net.minecraftforge.eventbus.api.SubscribeEvent - public void onPlayerLogin(PlayerLoggedInEvent e) - { - if (channel == null) - { - return; - } - PacketBuffer buffer = new PacketBuffer(Unpooled.buffer()); - buffer.writeByte(0); - channel.sendTo(new FMLProxyPacket(buffer, MOD_ID), (EntityPlayerMP) e.player); // disconnects vanilla clients in 1.11 - } - - @SubscribeEvent - public void onClientRecievedPacket(FMLNetworkEvent.ClientCustomPacketEvent event) - { - logger.info("Received packet from server"); - } -} -*/ diff --git a/src/test/java/net/minecraftforge/fml/test/SpecialSpawnEventTest.java b/src/test/java/net/minecraftforge/fml/test/SpecialSpawnEventTest.java deleted file mode 100644 index 55852ced22..0000000000 --- a/src/test/java/net/minecraftforge/fml/test/SpecialSpawnEventTest.java +++ /dev/null @@ -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.fml.test; - -import net.minecraft.entity.Entity; -import net.minecraft.entity.passive.EntityChicken; -import net.minecraft.init.Blocks; -import net.minecraft.tileentity.MobSpawnerBaseLogic; -import net.minecraftforge.common.MinecraftForge; -import net.minecraftforge.event.entity.living.LivingSpawnEvent; -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; - -//@Mod(modid = SpecialSpawnEventTest.MOD_ID, version = "1.0", acceptableRemoteVersions="*") -public class SpecialSpawnEventTest { - private static final boolean ENABLED = false; - public static final String MOD_ID = "spawnerduratest"; - - @EventHandler - public void onPreInit(FMLPreInitializationEvent e) - { - if (ENABLED) - { - MinecraftForge.EVENT_BUS.register(this); - } - - } - - @SubscribeEvent - public void specialSpawnEvent(LivingSpawnEvent.SpecialSpawn e) - { - MobSpawnerBaseLogic spawner = e.getSpawner(); - if (spawner == null) return; - if (spawner.getSpawnerEntity() != null) - { - Entity spawn = new EntityChicken(e.getWorld()); - spawn.copyLocationAndAnglesFrom(spawner.getSpawnerEntity()); - e.getWorld().spawnEntity(spawn); - spawner.getSpawnerEntity().setDead(); - } - else - { - e.getWorld().setBlockState(spawner.getSpawnerPosition(), Blocks.FIRE.getDefaultState()); - } - } -} -*/ diff --git a/src/test/java/net/minecraftforge/test/BiomeSpawnableListTest.java b/src/test/java/net/minecraftforge/test/BiomeSpawnableListTest.java deleted file mode 100644 index 2bdcad32e9..0000000000 --- a/src/test/java/net/minecraftforge/test/BiomeSpawnableListTest.java +++ /dev/null @@ -1,95 +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.test; - -import net.minecraft.block.material.Material; -import net.minecraft.entity.EntityLiving; -import net.minecraft.entity.EnumCreatureType; -import net.minecraft.entity.passive.AbstractHorse; -import net.minecraft.entity.passive.EntityHorse; -import net.minecraft.init.Biomes; -import net.minecraft.init.Bootstrap; -import net.minecraft.world.biome.Biome; -import net.minecraftforge.common.util.EnumHelper; -import net.minecraftforge.fml.common.Loader; -import net.minecraftforge.fml.common.registry.EntityRegistry; -import net.minecraftforge.fml.common.registry.ForgeTestRunner; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.runner.RunWith; - -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; - -@RunWith(ForgeTestRunner.class) -public class BiomeSpawnableListTest -{ - private static EnumCreatureType creatureTypeHorse; - - @BeforeClass - public static void setUp() throws Exception - { - Loader.instance(); - Bootstrap.register(); - creatureTypeHorse = EnumHelper.addCreatureType("biomespawnablelisttest:horse", AbstractHorse.class, 20, Material.AIR, true, true); - } - - private boolean spawnableListContainsEntry(Class entityClass, int weightedProb, int minGroupCount, int maxGroupCount, - EnumCreatureType creatureType, Biome biome) - { - boolean found = false; - - for (Biome.SpawnListEntry spawnListEntry : biome.getSpawnableList(creatureType)) - { - if (spawnListEntry.entityClass == entityClass && spawnListEntry.itemWeight == weightedProb && spawnListEntry.minGroupCount == minGroupCount - && spawnListEntry.maxGroupCount == maxGroupCount) - { - found = true; - break; - } - } - - return found; - } - - @Test - public void testAddAndRemoveSpawn() throws Exception - { - final Class entityClass = EntityHorse.class; - final int weightedProb = 1; - final int minGroupCount = 1; - final int maxGroupCount = 20; - final Biome biome = Biomes.PLAINS; - - // Test 1: We can add a spawn for the non-vanilla EnumCreatureType - EntityRegistry.addSpawn(entityClass, weightedProb, minGroupCount, maxGroupCount, creatureTypeHorse, biome); - final boolean containsEntryAfterAdd = spawnableListContainsEntry(entityClass, weightedProb, minGroupCount, maxGroupCount, creatureTypeHorse, biome); - assertTrue("The SpawnListEntry wasn't added", containsEntryAfterAdd); - - // Test 2: We can remove a spawn for the non-vanilla EnumCreatureType - EntityRegistry.removeSpawn(entityClass, creatureTypeHorse, biome); - final boolean containsEntryAfterRemove = spawnableListContainsEntry(entityClass, weightedProb, minGroupCount, maxGroupCount, creatureTypeHorse, biome); - assertFalse("The SpawnListEntry wasn't removed", containsEntryAfterRemove); - } -} -*/ diff --git a/src/test/java/net/minecraftforge/test/BufferBuilderExpansionTest.java b/src/test/java/net/minecraftforge/test/BufferBuilderExpansionTest.java deleted file mode 100644 index d9e6391b02..0000000000 --- a/src/test/java/net/minecraftforge/test/BufferBuilderExpansionTest.java +++ /dev/null @@ -1,156 +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.test; - -import net.minecraft.client.renderer.BufferBuilder; -import net.minecraft.client.renderer.vertex.DefaultVertexFormats; -import net.minecraft.client.renderer.vertex.VertexFormat; -import org.junit.Test; - -import java.util.Arrays; -import java.nio.ByteBuffer; - -import static org.junit.Assert.assertTrue; - -public class BufferBuilderExpansionTest -{ - - public VertexFormat format = DefaultVertexFormats.POSITION; - // 4 quads. - public int num_quads = 4; - public int BUFFER_SIZE = format.getNextOffset() * (num_quads * 4); - - @Test//Test the expansion of the buffer with addVertexData - public void testAddVertexExpansion() - { - BufferBuilder buffer = new BufferBuilder(BUFFER_SIZE / 4); - int prevCap = buffer.getByteBuffer().capacity(); - - int[] ints = new int[3 * 4];// 3 floats per the 4 vertices. - Arrays.fill(ints, Float.floatToIntBits(1.233F));//Just a random value. - - buffer.begin(0x07, format); - for (int i = 0; i < num_quads + 2; i++) - { - buffer.addVertexData(ints); - } - buffer.finishDrawing(); - - assertTrue("BufferBuilder's capacity didn't change.", buffer.getByteBuffer().capacity() > prevCap); - } - - @Test//Test the expansion of the buffer with endVertex. - public void testEndVertexExpansion() - { - BufferBuilder buffer = new BufferBuilder(BUFFER_SIZE / 4); - int prevCap = buffer.getByteBuffer().capacity(); - - buffer.begin(0x07, format); - for (int i = 0; i < num_quads + 2; i++) - { - for (int j = 0; j < 4; j++) - { - buffer.pos(1.233, 1.233, 1.233).endVertex(); - } - } - buffer.finishDrawing(); - - assertTrue("BufferBuilder's capacity didn't change.", buffer.getByteBuffer().capacity() > prevCap); - } - - @Test//Test the expansion of the buffer if addVertexData fills it and pos / tex / endVertex is used. - public void testMixedExpansion() - { - BufferBuilder buffer = new BufferBuilder(BUFFER_SIZE / 4); - int prevCap = buffer.getByteBuffer().capacity(); - - int[] ints = new int[3 * 4]; - Arrays.fill(ints, Float.floatToIntBits(1.233F)); - - buffer.begin(0x07, format); - for (int i = 0; i < num_quads; i++) - { - buffer.addVertexData(ints); - } - - for (int i = 0; i < num_quads + 2; i++) - { - for (int j = 0; j < 4; j++) - { - buffer.pos(1.233, 1.233, 1.233).endVertex(); - } - } - buffer.finishDrawing(); - - assertTrue("BufferBuilder's capacity didn't change.", buffer.getByteBuffer().capacity() > prevCap); - } - - @Test//Test the expansion of the buffer with putBulkData - public void testAddVertexExpansionBytes() - { - BufferBuilder buffer = new BufferBuilder(BUFFER_SIZE / 4); - int prevCap = buffer.getByteBuffer().capacity(); - - ByteBuffer buf = ByteBuffer.allocate(3 * 4 * 4); //3 floats per the 4 verticles (32bit float as 4 8bit bytes) - for(int i=0;i<4;i++) - buf.putFloat(1.233F); //Just a random value. - - buffer.begin(0x07, format); - for (int i = 0; i < num_quads + 2; i++) - { - buffer.putBulkData(buf); - } - buffer.finishDrawing(); - - assertTrue("BufferBuilder's capacity didn't change.", buffer.getByteBuffer().capacity() > prevCap); - } - - @Test//Test the expansion of the buffer if putBulkData fills it and pos / tex / endVertex is used. - public void testMixedExpansionBytes() - { - BufferBuilder buffer = new BufferBuilder(BUFFER_SIZE / 4); - int prevCap = buffer.getByteBuffer().capacity(); - - ByteBuffer buf = ByteBuffer.allocate(3 * 4 * 4); - for(int i=0;i<4;i++) - buf.putFloat(1.233F); - - buffer.begin(0x07, format); - for (int i = 0; i < num_quads; i++) - { - buffer.putBulkData(buf); - } - - for (int i = 0; i < num_quads + 2; i++) - { - for (int j = 0; j < 4; j++) - { - buffer.pos(1.233, 1.233, 1.233).endVertex(); - } - } - buffer.finishDrawing(); - - assertTrue("BufferBuilder's capacity didn't change.", buffer.getByteBuffer().capacity() > prevCap); - } -} -*/ diff --git a/src/test/java/net/minecraftforge/test/ConfigurationTest.java b/src/test/java/net/minecraftforge/test/ConfigurationTest.java deleted file mode 100644 index 41368bb425..0000000000 --- a/src/test/java/net/minecraftforge/test/ConfigurationTest.java +++ /dev/null @@ -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.test; - - -import net.minecraft.init.Bootstrap; -import net.minecraftforge.common.config.ConfigCategory; -import net.minecraftforge.common.config.Configuration; -import net.minecraftforge.common.config.Property; -import net.minecraftforge.fml.common.Loader; -import net.minecraftforge.fml.common.registry.ForgeTestRunner; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.runner.RunWith; - -import static junit.framework.TestCase.assertNull; -import static org.junit.Assert.*; - -@RunWith(ForgeTestRunner.class) -public class ConfigurationTest { - - private Configuration config; - private ConfigCategory category; - - @BeforeClass - public static void setupClass() - { - Loader.instance(); - Bootstrap.register(); - } - - @Before - public void setup() - { - Property enabledProperty = new Property("enabled", "true", Property.Type.BOOLEAN); - enabledProperty.setComment("enabled property comment"); - - Property backgroundProperty = new Property("background", "0xFFFFFF", Property.Type.COLOR); - backgroundProperty.setComment("background property comment"); - - config = new Configuration(); - category = config.getCategory("defaults"); - category.put(enabledProperty.getName(), enabledProperty); - category.put(backgroundProperty.getName(), backgroundProperty); - } - - @Test - public void testRenameProperty_newNameNotInUse() - { - boolean propertyRenamed = config.renameProperty("defaults", "enabled", "defaultEnabled"); - - Property enabledProperty = category.get("enabled"); - Property defaultEnabledProperty = category.get("defaultEnabled"); - - assertTrue("Property was not renamed", propertyRenamed); - assertNull("Old property was not removed", enabledProperty); - assertNotNull("New property was not added", defaultEnabledProperty); - assertEquals("The property's name was not changed", "defaultEnabled", defaultEnabledProperty.getName()); - assertEquals("The property's value changed", "true", defaultEnabledProperty.getString()); - assertEquals("The property's type was changed", Property.Type.BOOLEAN, defaultEnabledProperty.getType()); - assertEquals("The property's comment was changed", "enabled property comment", defaultEnabledProperty.getComment()); - } - - @Test - public void testRenameProperty_newNameInUse_replaceExistingProperty() - { - boolean propertyRenamed = config.renameProperty("defaults", "enabled", "background"); - - Property enabledProperty = category.get("enabled"); - Property backgroundProperty = category.get("background"); - - assertTrue("Property was not renamed", propertyRenamed); - assertNull("Old property was not removed", enabledProperty); - assertNotNull("New property was not added", backgroundProperty); - assertEquals("The property's name was not changed", "background", backgroundProperty.getName()); - assertEquals("The property's value changed", "true", backgroundProperty.getString()); - assertEquals("The property's type was changed", Property.Type.BOOLEAN, backgroundProperty.getType()); - assertEquals("The property's comment was changed", "enabled property comment", backgroundProperty.getComment()); - } -} -*/ diff --git a/src/test/java/net/minecraftforge/test/EnumHelperTest.java b/src/test/java/net/minecraftforge/test/EnumHelperTest.java deleted file mode 100644 index d77090a312..0000000000 --- a/src/test/java/net/minecraftforge/test/EnumHelperTest.java +++ /dev/null @@ -1,186 +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.test; - -import com.google.common.base.Joiner; -import com.google.common.base.Throwables; -import net.minecraft.enchantment.EnumEnchantmentType; -import net.minecraft.entity.EntityLiving; -import net.minecraft.entity.passive.HorseArmorType; -import net.minecraft.init.Bootstrap; -import net.minecraftforge.client.EnumHelperClient; -import net.minecraftforge.common.BiomeDictionary; -import net.minecraftforge.common.util.EnumHelper; -import org.junit.Assert; -import org.junit.Test; - -import java.lang.reflect.Constructor; -import java.lang.reflect.Field; -import java.lang.reflect.Method; -import java.lang.reflect.Modifier; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashSet; -import java.util.List; -import java.util.Set; - -public class EnumHelperTest -{ - private static final Joiner COMMA = Joiner.on(","); - - private static void setBootstrap() - { - try - { - for (Field f : Bootstrap.class.getDeclaredFields()) - { - if (Modifier.isPrivate(f.getModifiers()) && Modifier.isStatic(f.getModifiers()) && f.getType() == boolean.class) - { - f.setAccessible(true); - f.set(null, true); - } - } - } - catch (Exception e) - { - Throwables.propagate(e); - } - } - - @Test - public void testEnumHelperMethodsMatchEnumConstructors() - { - setBootstrap(); - - boolean failed = false; - Set> seenCtrs = new HashSet>(); - Set> matchedCtrs = new HashSet>(); - - //Quick note to point out that Enum constructors start with (string name, int ordinal). - // EnumHelper methods by convention start with (string name), and the ordinal is calculated. - List mtds = new ArrayList(); - mtds.addAll(Arrays.asList(EnumHelper.class.getDeclaredMethods())); - mtds.addAll(Arrays.asList(EnumHelperClient.class.getDeclaredMethods())); - - for (Method method : mtds) - { - String name = method.getName(); - if (!name.equals("addEnum") && name.startsWith("add") && Modifier.isPublic(method.getModifiers())) - { - //System.out.println(" " + method); - - Class returnType = method.getReturnType(); - Constructor[] declaredConstructors = returnType.getDeclaredConstructors(); - Class[] actualParameters = method.getParameterTypes(); - - Assert.assertTrue(actualParameters.length >= 1); - Assert.assertEquals("First parameter of add method should be String (name)", - String.class, - actualParameters[0]); - - actualParameters = Arrays.copyOfRange(actualParameters, 1, actualParameters.length); //Trim off name - String info = - " Method: " + method.getDeclaringClass().getSimpleName() + "." + method.getName() + "\n" + - " Class: " + returnType.getName() + "\n" + - " Actual: " + COMMA.join(actualParameters); - - boolean found = false; // There can sometimes be multiple constructors. - - for (Constructor declaredConstructor : declaredConstructors) - { - boolean filter = declaredConstructor.isSynthetic(); - - if (returnType == EnumEnchantmentType.class && declaredConstructor.getParameterTypes().length == 2) - { - filter = true; //We don't want people using this method. - } - if (returnType == EntityLiving.SpawnPlacementType.class && declaredConstructor.getParameterTypes().length == 2) - { - filter = true; //We don't want people using this method. - } - if (returnType == HorseArmorType.class && (declaredConstructor.getParameterTypes().length == 3 || declaredConstructor.getParameterTypes()[2] == int.class)) - { - filter = true; //We don't want people using either of these methods. - } - - if (!filter) - { - seenCtrs.add(declaredConstructor); - } - //System.out.println(" " + declaredConstructor.toString()); - - Class[] expectedParameters = declaredConstructor.getParameterTypes(); - - Assert.assertTrue(expectedParameters.length >= 2); - Assert.assertEquals("First parameter of enum constructor should be String (name)", - String.class, - expectedParameters[0]); - Assert.assertEquals("Second parameter of enum should be int (ordinal)", - int.class, - expectedParameters[1]); - - expectedParameters = Arrays.copyOfRange(expectedParameters, 2, expectedParameters.length); - - info += "\n Expected: " + COMMA.join(expectedParameters); - - if (Arrays.equals(actualParameters, expectedParameters)) - { - matchedCtrs.add(declaredConstructor); - found = true; - } - } - - if (!found) - { - System.out.println("Parameters did not Match:"); - System.out.println(info); - failed = true; - } - } - } - - seenCtrs.removeAll(matchedCtrs); - if (!seenCtrs.isEmpty()) - { - for (Constructor ctr : seenCtrs) - { - System.out.println("Missing accessor for Enum:"); - System.out.println(" Class: " + ctr.getName()); - System.out.println(" Params: " + COMMA.join(Arrays.copyOfRange(ctr.getParameterTypes(), 2, ctr.getParameterTypes().length))); - } - failed = true; - } - - Assert.assertFalse(failed); - } - - @Test - public void testEnumHelperTypes() - { - setBootstrap(); - Assert.assertEquals(BiomeDictionary.Type.BEACH, BiomeDictionary.Type.getType("BEACH")); - // This works, it's been tested, find a way to make this a unit test... - //Assert.assertEquals(BiomeDictionary.Type.getType("NEWTYPE"), BiomeDictionary.Type.getType("NEWTYPE")); - } -} -*/ diff --git a/src/test/java/net/minecraftforge/test/SelectorHandlerTest.java b/src/test/java/net/minecraftforge/test/SelectorHandlerTest.java deleted file mode 100644 index 48bdec489d..0000000000 --- a/src/test/java/net/minecraftforge/test/SelectorHandlerTest.java +++ /dev/null @@ -1,73 +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.test; - -import java.util.Collections; -import java.util.List; - -import net.minecraft.command.CommandException; -import net.minecraft.command.ICommandSender; -import net.minecraft.entity.Entity; -import net.minecraftforge.common.command.SelectorHandler; -import net.minecraftforge.common.command.SelectorHandlerManager; -import net.minecraftforge.fml.common.Mod; -import net.minecraftforge.fml.common.Mod.EventHandler; -import net.minecraftforge.fml.event.FMLInitializationEvent; - -//@Mod(modid = "selectorhandlertest", name = "Selector Handler Test", version = "0.0.0", acceptableRemoteVersions = "*") -public class SelectorHandlerTest -{ - @EventHandler - public void init(final FMLInitializationEvent event) - { - SelectorHandlerManager.register(Handler.name, new Handler()); - } - - private static class Handler implements SelectorHandler - { - protected static final String name = "@self"; - - @SuppressWarnings("unchecked") - @Override - public List matchEntities(final ICommandSender sender, final String token, final Class targetClass) throws CommandException - { - final Entity senderEntity = sender.getCommandSenderEntity(); - return senderEntity != null && targetClass.isAssignableFrom(senderEntity.getClass()) && name.equals(token) - ? Collections.singletonList((T) sender.getCommandSenderEntity()) - : Collections. emptyList(); - } - - @Override - public boolean matchesMultiplePlayers(final String selectorStr) throws CommandException - { - return false; - } - - @Override - public boolean isSelector(final String selectorStr) - { - return name.equals(selectorStr); - } - } -} -*/ diff --git a/src/test/java/net/minecraftforge/test/TestAnnotationParser.java b/src/test/java/net/minecraftforge/test/TestAnnotationParser.java deleted file mode 100644 index 172c2586f8..0000000000 --- a/src/test/java/net/minecraftforge/test/TestAnnotationParser.java +++ /dev/null @@ -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.test; - -import javax.annotation.Nullable; -import java.io.File; -import java.io.IOException; -import java.io.InputStream; -import java.net.URL; -import java.util.Collections; -import java.util.regex.Matcher; -import java.util.regex.Pattern; -import java.util.zip.ZipEntry; -import java.util.zip.ZipFile; - -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; - -import net.minecraftforge.fml.common.discovery.json.JsonAnnotationLoader; -import org.junit.jupiter.api.Test; - -public class TestAnnotationParser -{ - // To test, put any mod jar into src/test/resources and put the jar name below - private static String TEST_JAR = "forestry_1.12.2-5.8.0.242.jar"; - public static Pattern classFile = Pattern.compile("[^\\s\\$]+(\\$[^\\s]+)?\\.class$"); - private static final int RUN_COUNT = 100; - private static final Logger LOG = LogManager.getLogger("TestAnnotationParser"); - - @Nullable - private File getFile() - { - ClassLoader cl = getClass().getClassLoader(); - URL url = cl.getResource(TEST_JAR); - return url == null ? null : new File(url.getFile()); - } - - @Test - public void testAnnotationLoaderASM() throws IOException - { - File jar = getFile(); - if (jar == null) - { - LOG.fatal("Could not find test mod jar: {}", TEST_JAR); - return; //Skip this test if the test jar doesn't exist. - } - - Timer timer = new Timer(); - for( int x = 0; x < RUN_COUNT; x++) - { - timer.start(); - loadAnnotationsASM(jar); - timer.end(null); - } - LOG.info("LoaderASM: {}", timer.finish()); - } - - @Test - public void testAnnotationLoaderJSON() throws IOException - { - File jar = getFile(); - if (jar == null) - { - LOG.fatal("Could not find test mod jar: {}", TEST_JAR); - return; //Skip this test if the test jar doesn't exist. - } - - Timer timer = new Timer(); - for( int x = 0; x < RUN_COUNT; x++) - { - timer.start(); - loadAnnotationsJSON(jar); - timer.end(null); - } - LOG.info("LoaderJSON: {}", timer.finish()); - } - - private void loadAnnotationsASM(File jar) throws IOException - { - ASMDataTable dataTable = new ASMDataTable(); - ModCandidate candidate = new ModCandidate(jar, jar, ContainerType.JAR); - try (ZipFile in = new ZipFile(jar)) - { - for (ZipEntry e : Collections.list(in.entries())) - { - if (e.getName() != null && e.getName().startsWith("__MACOSX")) - continue; - - Matcher match = classFile.matcher(e.getName()); - if (match.matches()) - { - ASMModParser modParser = null; - try (InputStream inputStream = in.getInputStream(e)) - { - modParser = new ASMModParser(inputStream); - } - catch (IOException exception) - { - LOG.error("Failed to create ASMModParser:", exception); - } - //candidate.addClassEntry(e.getName()); - if (modParser != null) - { - modParser.sendToTable(dataTable, candidate); - } - } - } - } - } - - private void loadAnnotationsJSON(File jar) throws IOException - { - ASMDataTable dataTable = new ASMDataTable(); - ModCandidate candidate = new ModCandidate(jar, jar, ContainerType.JAR); - try (ZipFile in = new ZipFile(jar)) - { - // We need to loop everything to gather a list of class files, but as we're not reading every entry we should be faster? - for (ZipEntry e : Collections.list(in.entries())) - { - if (e.getName() != null && e.getName().startsWith("__MACOSX")) - continue; - - Matcher match = classFile.matcher(e.getName()); - if (match.matches()) - { - //We check for classes, make this fancier and support multi-release jars? - //candidate.addClassEntry(e.getName()); - } - } - - InputStream json_input = in.getInputStream(in.getEntry(JsonAnnotationLoader.ANNOTATION_JSON)); - JsonAnnotationLoader.loadJson(json_input, candidate, dataTable); - } - } - - private static class Timer - { - private long start; - private long min = Long.MAX_VALUE; - private long max = Long.MIN_VALUE; - private long total = 0; - private int count = 0; - - public void start() - { - this.start = System.currentTimeMillis(); - } - - public void end(@Nullable String message) - { - long now = System.currentTimeMillis(); - long time = now - start; - if (message != null) - { - LOG.info("{} {}", message, time); - } - min = Long.min(min, time); - max = Long.max(max, time); - total += time; - count++; - } - - public String finish() - { - return "Runs: " + count + - " Min: " + min + "ms" + - " Max: " + max + "ms" + - " Total: " + total + "ms" + - " Average: " + total / count + "ms"; - } - } -} -*/ diff --git a/src/test/java/net/minecraftforge/test/TestProgressBar.java b/src/test/java/net/minecraftforge/test/TestProgressBar.java deleted file mode 100644 index 88bc2a9aab..0000000000 --- a/src/test/java/net/minecraftforge/test/TestProgressBar.java +++ /dev/null @@ -1,199 +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.test; - -import net.minecraftforge.fml.common.progress.IProgressBarTracker; -import net.minecraftforge.fml.common.progress.ProgressBar; -import org.apache.commons.lang3.tuple.Pair; -import org.junit.jupiter.api.Test; - -import java.util.List; -import java.util.concurrent.CopyOnWriteArrayList; -import java.util.concurrent.atomic.AtomicBoolean; -import java.util.concurrent.atomic.AtomicInteger; - -public class TestProgressBar -{ - private static String getStepMessage(int step) - { - if (step == 0) - { - return ""; - } - return "testStep" + step; - } - - private static void checkBarState(int step, String message, int expectedStepValue, int totalSteps) - { - if (step != expectedStepValue) - { - throw new IllegalStateException("Got step " + step + " but expected " + expectedStepValue); - } - if (step > totalSteps) - { - throw new IllegalStateException("ProgressBar stepped past the total: " + step + "/" + totalSteps); - } - String expectedMessage = getStepMessage(expectedStepValue); - if (!message.equals(expectedMessage)) - { - throw new IllegalStateException("Got message '" + message + "' but expected '" + expectedMessage + "'"); - } - } - - @Test - public void testProgressBar() - { - String title = "testTitle"; - final int totalSteps = 20; - - IProgressBarTracker tracker = new TestProgressBarTracker(totalSteps, title); - - try (ProgressBar progressBar = new ProgressBar(title, totalSteps, s -> s, tracker)) - { - String barTitle = progressBar.getTitle(); - if (!title.equals(barTitle)) - { - throw new IllegalStateException("Got title " + barTitle + " but expected " + title); - } - for (int i = 1; i <= totalSteps; i++) { - progressBar.step(getStepMessage(i)); - } - } - } - - @Test - public void testThreadedProgressBar() - { - String title = "testTitle"; - final int totalSteps = 10; - - TestProgressBarTracker tracker = new TestProgressBarTracker(totalSteps, title); - - AtomicBoolean threadSawBar = new AtomicBoolean(false); - Thread thread = new Thread(() -> - { - List bars = TestProgressBarTracker.getBars(); - while (bars.isEmpty()) - { - Thread.yield(); - bars = TestProgressBarTracker.getBars(); - } - while (!bars.isEmpty()) - { - for (ProgressBar bar : bars) - { - Pair stepAndMessage = bar.getStepAndMessage(); - int step = stepAndMessage.getLeft(); - String message = stepAndMessage.getRight(); - checkBarState(step, message, step, totalSteps); - threadSawBar.set(true); - } - Thread.yield(); - bars = TestProgressBarTracker.getBars(); - } - }); - thread.start(); - - try (ProgressBar progressBar = new ProgressBar(title, totalSteps, s -> s, tracker)) - { - String barTitle = progressBar.getTitle(); - if (!title.equals(barTitle)) - { - throw new IllegalStateException("Got title " + barTitle + " but expected " + title); - } - for (int i = 1; i <= totalSteps; i++) { - progressBar.step(getStepMessage(i)); - try - { - Thread.sleep(1); - } - catch (InterruptedException ignored) - { - - } - } - } - - if (!threadSawBar.get()) - { - throw new IllegalStateException("Thread never saw any progress bars"); - } - } - - private static class TestProgressBarTracker implements IProgressBarTracker - { - private static final List bars = new CopyOnWriteArrayList<>(); - private final AtomicInteger stepped = new AtomicInteger(0); - private final int totalSteps; - private final String title; - - public TestProgressBarTracker(int totalSteps, String title) - { - this.totalSteps = totalSteps; - this.title = title; - } - - @Override - public void onBarCreated(ProgressBar bar) - { - bars.add(bar); - int expectedStepCount = 0; - Pair stepAndMessage = bar.getStepAndMessage(); - Integer step = stepAndMessage.getLeft(); - String message = stepAndMessage.getRight(); - checkBarState(step, message, expectedStepCount, totalSteps); - } - - @Override - public void onStepStarted(ProgressBar bar, int step, String message) - { - int expectedStepCount = stepped.incrementAndGet(); - checkBarState(step, message, expectedStepCount, totalSteps); - } - - @Override - public void onStepFinished(ProgressBar bar, int step, String message) - { - int expectedStepCount = stepped.get(); - checkBarState(step, message, expectedStepCount, totalSteps); - } - - @Override - public void onBarFinished(ProgressBar bar, int step, String message) - { - bars.remove(bar); - int expectedStepCount = stepped.get(); - checkBarState(step, message, expectedStepCount, totalSteps); - if (step != totalSteps) - { - throw new IllegalStateException("ProgressBar did not finish: " + title + ".\nSteps: " + step + "/" + totalSteps); - } - } - - public static List getBars() - { - return bars; - } - } -} -*/ diff --git a/src/test/java/net/minecraftforge/test/package-info.java b/src/test/java/net/minecraftforge/test/package-info.java deleted file mode 100644 index edca8b927b..0000000000 --- a/src/test/java/net/minecraftforge/test/package-info.java +++ /dev/null @@ -1,26 +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.test; - -import mcp.MethodsReturnNonnullByDefault; - -import javax.annotation.ParametersAreNonnullByDefault; diff --git a/src/test/resources/META-INF/mods.toml b/src/test/resources/META-INF/mods.toml index 0115bbec84..cbfd420e2e 100644 --- a/src/test/resources/META-INF/mods.toml +++ b/src/test/resources/META-INF/mods.toml @@ -9,28 +9,16 @@ loaderVersion="[28,)" modId="base_block_place_event_test" [[mods]] modId="farmland_trample_test" -#[[mods]] -# modId="farmland_water_test" -##[[mods]] # Fluid System needs implementing -## modId="fog_color_in_material_test" [[mods]] modId="neighbor_notify_event_test" -#[[mods]] -# modId="block_particle_effects_test" -[[mods]] - modId="ai_node_type_test" [[mods]] modId="block_place_event_test" -#[[mods]] -# modId="portal_spawn_event_test" [[mods]] modId="slipperiness_test" [[mods]] modId="custom_slime_block_test" [[mods]] modId="client_chat_event_test" -##[[mods]] # Client Command System doesn't exist yet -## modId="client_command_test" [[mods]] modId="command_event_test" [[mods]] @@ -47,8 +35,6 @@ loaderVersion="[28,)" modId="flower_pot_test" [[mods]] modId="player_xp_event_test" -##[[mods]] -## modId="custom_tnt_test" [[mods]] modId="new_model_loader_test" [[mods]]