mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-18 11:29:15 +00:00
Regenerate patches with relative headers. This should lower conflicts in future PRs.
Convert Forge to use Official mappings. Mojang released their obfuscation mappings but we have not used them up until now due to wanting to get their license to be more explicitly permissive. It is clear that their intent is to allow us to use their names for developing mods like this. See the full wording, and our interpretation here: https://github.com/MinecraftForge/MCPConfig/blob/master/Mojang.md
This commit is contained in:
1 parent
802298d99d
commit
a95b968c13
832 files changed
+4464
-4373
No files matched your search
@@ -50,10 +50,10 @@ public class CustomSoundTypeTest
|
||||
private static final SoundType TEST_SOUND_TYPE = new ForgeSoundType(1.0F, 1.0F, TEST_STEP_EVENT, TEST_STEP_EVENT, TEST_STEP_EVENT, TEST_STEP_EVENT, TEST_STEP_EVENT);
|
||||
|
||||
private static final RegistryObject<Block> TEST_STEP_BLOCK = BLOCKS.register("test_block",
|
||||
() -> new Block(AbstractBlock.Properties.create(Material.WOOD).sound(TEST_SOUND_TYPE)));
|
||||
() -> new Block(AbstractBlock.Properties.of(Material.WOOD).sound(TEST_SOUND_TYPE)));
|
||||
|
||||
private static final RegistryObject<Item> TEST_STEP_BLOCK_ITEM = ITEMS.register("test_block",
|
||||
() -> new BlockItem(TEST_STEP_BLOCK.get(), new Item.Properties().group(ItemGroup.MISC)));
|
||||
() -> new BlockItem(TEST_STEP_BLOCK.get(), new Item.Properties().tab(ItemGroup.TAB_MISC)));
|
||||
|
||||
public CustomSoundTypeTest()
|
||||
{
|
||||
|
||||
@@ -132,7 +132,7 @@ public class DataGeneratorTest
|
||||
super(gen);
|
||||
}
|
||||
|
||||
protected void registerRecipes(Consumer<IFinishedRecipe> consumer)
|
||||
protected void buildShapelessRecipes(Consumer<IFinishedRecipe> consumer)
|
||||
{
|
||||
ResourceLocation ID = new ResourceLocation("data_gen_test", "conditional");
|
||||
|
||||
@@ -145,14 +145,14 @@ public class DataGeneratorTest
|
||||
)
|
||||
)
|
||||
.addRecipe(
|
||||
ShapedRecipeBuilder.shapedRecipe(Blocks.DIAMOND_BLOCK, 64)
|
||||
.patternLine("XXX")
|
||||
.patternLine("XXX")
|
||||
.patternLine("XXX")
|
||||
.key('X', Blocks.DIRT)
|
||||
.setGroup("")
|
||||
.addCriterion("has_dirt", hasItem(Blocks.DIRT)) // DUMMY: Necessary, but not used when a custom advancement is provided through setAdvancement
|
||||
::build
|
||||
ShapedRecipeBuilder.shaped(Blocks.DIAMOND_BLOCK, 64)
|
||||
.pattern("XXX")
|
||||
.pattern("XXX")
|
||||
.pattern("XXX")
|
||||
.define('X', Blocks.DIRT)
|
||||
.group("")
|
||||
.unlockedBy("has_dirt", has(Blocks.DIRT)) // DUMMY: Necessary, but not used when a custom advancement is provided through setAdvancement
|
||||
::save
|
||||
)
|
||||
.setAdvancement(ID,
|
||||
ConditionalAdvancement.builder()
|
||||
@@ -164,15 +164,15 @@ public class DataGeneratorTest
|
||||
)
|
||||
)
|
||||
.addAdvancement(
|
||||
Advancement.Builder.builder()
|
||||
.withParentId(new ResourceLocation("minecraft", "root"))
|
||||
.withDisplay(Blocks.DIAMOND_BLOCK,
|
||||
Advancement.Builder.advancement()
|
||||
.parent(new ResourceLocation("minecraft", "root"))
|
||||
.display(Blocks.DIAMOND_BLOCK,
|
||||
new StringTextComponent("Dirt2Diamonds"),
|
||||
new StringTextComponent("The BEST crafting recipe in the game!"),
|
||||
null, FrameType.TASK, false, false, false
|
||||
)
|
||||
.withRewards(AdvancementRewards.Builder.recipe(ID))
|
||||
.withCriterion("has_dirt", hasItem(Blocks.DIRT))
|
||||
.rewards(AdvancementRewards.Builder.recipe(ID))
|
||||
.addCriterion("has_dirt", has(Blocks.DIRT))
|
||||
)
|
||||
)
|
||||
.build(consumer, ID);
|
||||
@@ -188,14 +188,14 @@ public class DataGeneratorTest
|
||||
)
|
||||
)
|
||||
.addRecipe(
|
||||
ShapedRecipeBuilder.shapedRecipe(Blocks.DIAMOND_BLOCK, 64)
|
||||
.patternLine("XXX")
|
||||
.patternLine("XXX")
|
||||
.patternLine("XXX")
|
||||
.key('X', Blocks.DIRT)
|
||||
.setGroup("")
|
||||
.addCriterion("has_dirt", hasItem(Blocks.DIRT))
|
||||
::build
|
||||
ShapedRecipeBuilder.shaped(Blocks.DIAMOND_BLOCK, 64)
|
||||
.pattern("XXX")
|
||||
.pattern("XXX")
|
||||
.pattern("XXX")
|
||||
.define('X', Blocks.DIRT)
|
||||
.group("")
|
||||
.unlockedBy("has_dirt", has(Blocks.DIRT))
|
||||
::save
|
||||
)
|
||||
.generateAdvancement()
|
||||
.build(consumer, new ResourceLocation("data_gen_test", "conditional2"));
|
||||
@@ -210,27 +210,27 @@ public class DataGeneratorTest
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void registerTags()
|
||||
protected void addTags()
|
||||
{
|
||||
getOrCreateBuilder(BlockTags.makeWrapperTag(new ResourceLocation(MODID, "test").toString()))
|
||||
.addItemEntry(Blocks.DIAMOND_BLOCK)
|
||||
tag(BlockTags.bind(new ResourceLocation(MODID, "test").toString()))
|
||||
.add(Blocks.DIAMOND_BLOCK)
|
||||
.addTag(BlockTags.STONE_BRICKS)
|
||||
.addTag(net.minecraftforge.common.Tags.Blocks.COBBLESTONE)
|
||||
.addOptional(new ResourceLocation("chisel", "marble/raw"))
|
||||
.addOptionalTag(new ResourceLocation("forge", "storage_blocks/ruby"));
|
||||
|
||||
// Hopefully sorting issues
|
||||
getOrCreateBuilder(BlockTags.makeWrapperTag(new ResourceLocation(MODID, "thing/one").toString()))
|
||||
.addItemEntry(Blocks.COBBLESTONE);
|
||||
getOrCreateBuilder(BlockTags.makeWrapperTag(new ResourceLocation(MODID, "thing/two").toString()))
|
||||
.addItemEntry(Blocks.DIORITE);
|
||||
getOrCreateBuilder(BlockTags.makeWrapperTag(new ResourceLocation(MODID, "thing/three").toString()))
|
||||
.addItemEntry(Blocks.ANDESITE);
|
||||
tag(BlockTags.bind(new ResourceLocation(MODID, "thing/one").toString()))
|
||||
.add(Blocks.COBBLESTONE);
|
||||
tag(BlockTags.bind(new ResourceLocation(MODID, "thing/two").toString()))
|
||||
.add(Blocks.DIORITE);
|
||||
tag(BlockTags.bind(new ResourceLocation(MODID, "thing/three").toString()))
|
||||
.add(Blocks.ANDESITE);
|
||||
|
||||
getOrCreateBuilder(BlockTags.makeWrapperTag(new ResourceLocation(MODID, "things").toString()))
|
||||
.addItemEntry(Blocks.COBBLESTONE)
|
||||
.addItemEntry(Blocks.DIORITE)
|
||||
.addItemEntry(Blocks.ANDESITE);
|
||||
tag(BlockTags.bind(new ResourceLocation(MODID, "things").toString()))
|
||||
.add(Blocks.COBBLESTONE)
|
||||
.add(Blocks.DIORITE)
|
||||
.add(Blocks.ANDESITE);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -302,9 +302,9 @@ public class DataGeneratorTest
|
||||
);
|
||||
|
||||
@Override
|
||||
public void act(DirectoryCache cache) throws IOException
|
||||
public void run(DirectoryCache cache) throws IOException
|
||||
{
|
||||
super.act(cache);
|
||||
super.run(cache);
|
||||
List<String> errors = testModelResults(this.generatedModels, existingFileHelper, IGNORED_MODELS.stream().map(s -> new ResourceLocation(MODID, folder + "/" + s)).collect(Collectors.toSet()));
|
||||
if (!errors.isEmpty()) {
|
||||
LOGGER.error("Found {} discrepancies between generated and vanilla item models: ", errors.size());
|
||||
@@ -341,11 +341,11 @@ public class DataGeneratorTest
|
||||
ModelFile birchFenceGateWallOpen = models().fenceGateWallOpen("birch_fence_gate_wall_open", mcLoc("block/birch_planks"));
|
||||
ModelFile invisbleModel = new UncheckedModelFile(new ResourceLocation("builtin/generated"));
|
||||
VariantBlockStateBuilder builder = getVariantBuilder(Blocks.BIRCH_FENCE_GATE);
|
||||
for (Direction dir : FenceGateBlock.HORIZONTAL_FACING.getAllowedValues()) {
|
||||
int angle = (int) dir.getHorizontalAngle();
|
||||
for (Direction dir : FenceGateBlock.FACING.getPossibleValues()) {
|
||||
int angle = (int) dir.toYRot();
|
||||
builder
|
||||
.partialState()
|
||||
.with(FenceGateBlock.HORIZONTAL_FACING, dir)
|
||||
.with(FenceGateBlock.FACING, dir)
|
||||
.with(FenceGateBlock.IN_WALL, false)
|
||||
.with(FenceGateBlock.OPEN, false)
|
||||
.modelForState()
|
||||
@@ -357,7 +357,7 @@ public class DataGeneratorTest
|
||||
.weight(100)
|
||||
.addModel()
|
||||
.partialState()
|
||||
.with(FenceGateBlock.HORIZONTAL_FACING, dir)
|
||||
.with(FenceGateBlock.FACING, dir)
|
||||
.with(FenceGateBlock.IN_WALL, false)
|
||||
.with(FenceGateBlock.OPEN, true)
|
||||
.modelForState()
|
||||
@@ -366,7 +366,7 @@ public class DataGeneratorTest
|
||||
.uvLock(true)
|
||||
.addModel()
|
||||
.partialState()
|
||||
.with(FenceGateBlock.HORIZONTAL_FACING, dir)
|
||||
.with(FenceGateBlock.FACING, dir)
|
||||
.with(FenceGateBlock.IN_WALL, true)
|
||||
.with(FenceGateBlock.OPEN, false)
|
||||
.modelForState()
|
||||
@@ -375,7 +375,7 @@ public class DataGeneratorTest
|
||||
.uvLock(true)
|
||||
.addModel()
|
||||
.partialState()
|
||||
.with(FenceGateBlock.HORIZONTAL_FACING, dir)
|
||||
.with(FenceGateBlock.FACING, dir)
|
||||
.with(FenceGateBlock.IN_WALL, true)
|
||||
.with(FenceGateBlock.OPEN, true)
|
||||
.modelForState()
|
||||
@@ -424,21 +424,21 @@ public class DataGeneratorTest
|
||||
models().getBuilder("cube")
|
||||
.parent(block)
|
||||
.element()
|
||||
.allFaces((dir, face) -> face.texture("#" + dir.getString()).cullface(dir));
|
||||
.allFaces((dir, face) -> face.texture("#" + dir.getSerializedName()).cullface(dir));
|
||||
|
||||
ModelFile furnace = models().orientable("furnace", mcLoc("block/furnace_side"), mcLoc("block/furnace_front"), mcLoc("block/furnace_top"));
|
||||
ModelFile furnaceLit = models().orientable("furnace_on", mcLoc("block/furnace_side"), mcLoc("block/furnace_front_on"), mcLoc("block/furnace_top"));
|
||||
|
||||
getVariantBuilder(Blocks.FURNACE)
|
||||
.forAllStates(state -> ConfiguredModel.builder()
|
||||
.modelFile(state.get(FurnaceBlock.LIT) ? furnaceLit : furnace)
|
||||
.rotationY((int) state.get(FurnaceBlock.FACING).getOpposite().getHorizontalAngle())
|
||||
.modelFile(state.getValue(FurnaceBlock.LIT) ? furnaceLit : furnace)
|
||||
.rotationY((int) state.getValue(FurnaceBlock.FACING).getOpposite().toYRot())
|
||||
.build()
|
||||
);
|
||||
|
||||
ModelFile barrel = models().cubeBottomTop("barrel", mcLoc("block/barrel_side"), mcLoc("block/barrel_bottom"), mcLoc("block/barrel_top"));
|
||||
ModelFile barrelOpen = models().cubeBottomTop("barrel_open", mcLoc("block/barrel_side"), mcLoc("block/barrel_bottom"), mcLoc("block/barrel_top_open"));
|
||||
directionalBlock(Blocks.BARREL, state -> state.get(BarrelBlock.PROPERTY_OPEN) ? barrelOpen : barrel); // Testing custom state interpreter
|
||||
directionalBlock(Blocks.BARREL, state -> state.getValue(BarrelBlock.OPEN) ? barrelOpen : barrel); // Testing custom state interpreter
|
||||
|
||||
logBlock((RotatedPillarBlock) Blocks.ACACIA_LOG);
|
||||
|
||||
@@ -474,9 +474,9 @@ public class DataGeneratorTest
|
||||
private List<String> errors = new ArrayList<>();
|
||||
|
||||
@Override
|
||||
public void act(DirectoryCache cache) throws IOException
|
||||
public void run(DirectoryCache cache) throws IOException
|
||||
{
|
||||
super.act(cache);
|
||||
super.run(cache);
|
||||
this.errors.addAll(testModelResults(models().generatedModels, models().existingFileHelper, Sets.union(IGNORED_MODELS, CUSTOM_MODELS)));
|
||||
this.registeredBlocks.forEach((block, state) -> {
|
||||
if (IGNORED_BLOCKS.contains(block)) return;
|
||||
|
||||
@@ -54,8 +54,8 @@ public class DeferredRegistryTest {
|
||||
private static final DeferredRegister<Item> ITEMS = DeferredRegister.create(ForgeRegistries.ITEMS, MODID);
|
||||
private static final DeferredRegister<Custom> CUSTOMS = DeferredRegister.create(Custom.class, MODID);
|
||||
|
||||
private static final RegistryObject<Block> BLOCK = BLOCKS.register("test", () -> new Block(Block.Properties.create(Material.ROCK)));
|
||||
private static final RegistryObject<Item> ITEM = ITEMS .register("test", () -> new BlockItem(BLOCK.get(), new Item.Properties().group(ItemGroup.BUILDING_BLOCKS)));
|
||||
private static final RegistryObject<Block> BLOCK = BLOCKS.register("test", () -> new Block(Block.Properties.of(Material.STONE)));
|
||||
private static final RegistryObject<Item> ITEM = ITEMS .register("test", () -> new BlockItem(BLOCK.get(), new Item.Properties().tab(ItemGroup.TAB_BUILDING_BLOCKS)));
|
||||
private static final RegistryObject<Custom> CUSTOM = CUSTOMS.register("test", () -> new Custom(){});
|
||||
|
||||
private static final Supplier<IForgeRegistry<Custom>> CUSTOM_REG = CUSTOMS.makeRegistry("test_registry", () ->
|
||||
|
||||
@@ -46,20 +46,20 @@ public class PotionEventTest
|
||||
|
||||
private void onSetup(FMLCommonSetupEvent event)
|
||||
{
|
||||
BrewingRecipeRegistry.addRecipe(Ingredient.fromItems(Items.ICE), Ingredient.fromItems(Items.LAVA_BUCKET), new ItemStack(Items.OBSIDIAN));
|
||||
BrewingRecipeRegistry.addRecipe(Ingredient.of(Items.ICE), Ingredient.of(Items.LAVA_BUCKET), new ItemStack(Items.OBSIDIAN));
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public static void onPotionAdded(PotionEvent.PotionAddedEvent event)
|
||||
{
|
||||
if (!event.getEntity().getEntityWorld().isRemote)
|
||||
if (!event.getEntity().getCommandSenderWorld().isClientSide)
|
||||
LOGGER.info("{} has a new PotionEffect {}, the old one was {}", event.getEntityLiving(), event.getPotionEffect(), event.getOldPotionEffect());
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public static void isPotionApplicable(PotionEvent.PotionApplicableEvent event)
|
||||
{
|
||||
if (!event.getEntity().getEntityWorld().isRemote)
|
||||
if (!event.getEntity().getCommandSenderWorld().isClientSide)
|
||||
{
|
||||
event.setResult(Result.ALLOW);
|
||||
LOGGER.info("Allowed Potion {} for Entity {}", event.getPotionEffect(), event.getEntityLiving());
|
||||
@@ -69,14 +69,14 @@ public class PotionEventTest
|
||||
@SubscribeEvent
|
||||
public static void onPotionRemove(PotionEvent.PotionRemoveEvent event)
|
||||
{
|
||||
if (!event.getEntity().getEntityWorld().isRemote)
|
||||
if (!event.getEntity().getCommandSenderWorld().isClientSide)
|
||||
LOGGER.info("Effect {} got Removed from {}", event.getPotionEffect(), event.getEntityLiving());
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public static void onPotionExpiry(PotionEvent.PotionExpiryEvent event)
|
||||
{
|
||||
if (!event.getEntity().getEntityWorld().isRemote)
|
||||
if (!event.getEntity().getCommandSenderWorld().isClientSide)
|
||||
LOGGER.info("Effect {} expired from {}", event.getPotionEffect(), event.getEntityLiving());
|
||||
}
|
||||
}
|
||||
@@ -69,14 +69,14 @@ public class CustomPlantTypeTest
|
||||
{
|
||||
public CustomBlock()
|
||||
{
|
||||
super(Block.Properties.create(Material.ROCK));
|
||||
super(Block.Properties.of(Material.STONE));
|
||||
this.setRegistryName(MODID, CUSTOM_SOIL_BLOCK);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canSustainPlant(BlockState state, IBlockReader world, BlockPos pos, Direction facing, IPlantable plantable)
|
||||
{
|
||||
PlantType type = plantable.getPlantType(world, pos.offset(facing));
|
||||
PlantType type = plantable.getPlantType(world, pos.relative(facing));
|
||||
if (type != null && type == CustomPlantBlock.pt)
|
||||
{
|
||||
return true;
|
||||
@@ -91,7 +91,7 @@ public class CustomPlantTypeTest
|
||||
|
||||
public CustomPlantBlock()
|
||||
{
|
||||
super(Effects.WEAKNESS, 9, Block.Properties.create(Material.PLANTS).doesNotBlockMovement().sound(SoundType.PLANT));
|
||||
super(Effects.WEAKNESS, 9, Block.Properties.of(Material.PLANT).noCollission().sound(SoundType.GRASS));
|
||||
this.setRegistryName(MODID, CUSTOM_PLANT_BLOCK);
|
||||
}
|
||||
|
||||
@@ -104,18 +104,18 @@ public class CustomPlantTypeTest
|
||||
@Override
|
||||
public BlockState getPlant(IBlockReader world, BlockPos pos)
|
||||
{
|
||||
return getDefaultState();
|
||||
return defaultBlockState();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValidPosition(BlockState state, IWorldReader world, BlockPos pos)
|
||||
public boolean canSurvive(BlockState state, IWorldReader world, BlockPos pos)
|
||||
{
|
||||
BlockState soil = world.getBlockState(pos.down());
|
||||
BlockState soil = world.getBlockState(pos.below());
|
||||
return soil.canSustainPlant(world, pos, Direction.UP, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValidGround(BlockState state, IBlockReader worldIn, BlockPos pos)
|
||||
public boolean mayPlaceOn(BlockState state, IBlockReader worldIn, BlockPos pos)
|
||||
{
|
||||
Block block = state.getBlock();
|
||||
return block == CUSTOM_SOIL;
|
||||
|
||||
@@ -44,9 +44,9 @@ public class FlowerPotTest
|
||||
private static final DeferredRegister<Block> BLOCKS = DeferredRegister.create(ForgeRegistries.BLOCKS, MODID);
|
||||
private static final DeferredRegister<Item> ITEMS = DeferredRegister.create(ForgeRegistries.ITEMS, MODID);
|
||||
|
||||
public static final RegistryObject<FlowerPotBlock> EMPTY_FLOWER_POT = BLOCKS.register(BLOCK_ID, () -> new FlowerPotBlock(null, Blocks.AIR.delegate, Block.Properties.from(Blocks.FLOWER_POT)));
|
||||
public static final RegistryObject<FlowerPotBlock> EMPTY_FLOWER_POT = BLOCKS.register(BLOCK_ID, () -> new FlowerPotBlock(null, Blocks.AIR.delegate, Block.Properties.copy(Blocks.FLOWER_POT)));
|
||||
public static final RegistryObject<FlowerPotBlock> OAK_FLOWER_POT = BLOCKS.<FlowerPotBlock>register(
|
||||
BLOCK_ID + "_oak", () -> new FlowerPotBlock(EMPTY_FLOWER_POT, Blocks.OAK_SAPLING.delegate, Block.Properties.from(Blocks.FLOWER_POT)));
|
||||
BLOCK_ID + "_oak", () -> new FlowerPotBlock(EMPTY_FLOWER_POT, Blocks.OAK_SAPLING.delegate, Block.Properties.copy(Blocks.FLOWER_POT)));
|
||||
|
||||
static {
|
||||
ITEMS.register(BLOCK_ID, () -> new BlockItem(EMPTY_FLOWER_POT.get(), new Item.Properties()));
|
||||
|
||||
@@ -36,9 +36,9 @@ public class HarvestToolTest
|
||||
{
|
||||
PlayerEntity player = event.getPlayer();
|
||||
BlockState state = event.getState();
|
||||
for (ToolType toolType : player.getHeldItemMainhand().getToolTypes()) {
|
||||
for (ToolType toolType : player.getMainHandItem().getToolTypes()) {
|
||||
if (state.isToolEffective(toolType)) {
|
||||
player.sendMessage(new StringTextComponent(String.format("Tool was effective. tool type: %s | harvest level: %d", toolType.getName(), state.getHarvestLevel())), player.getUniqueID());
|
||||
player.sendMessage(new StringTextComponent(String.format("Tool was effective. tool type: %s | harvest level: %d", toolType.getName(), state.getHarvestLevel())), player.getUUID());
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -68,9 +68,9 @@ public class PistonEventTest
|
||||
private static DeferredRegister<Block> BLOCKS = DeferredRegister.create(ForgeRegistries.BLOCKS, MODID);
|
||||
private static DeferredRegister<Item> ITEMS = DeferredRegister.create(ForgeRegistries.ITEMS, MODID);
|
||||
|
||||
private static RegistryObject<Block> shiftOnMove = BLOCKS.register(blockName, () -> new Block(Block.Properties.create(Material.ROCK)));
|
||||
private static RegistryObject<Block> shiftOnMove = BLOCKS.register(blockName, () -> new Block(Block.Properties.of(Material.STONE)));
|
||||
static {
|
||||
ITEMS.register(blockName, () -> new BlockItem(shiftOnMove.get(), new Item.Properties().group(ItemGroup.BUILDING_BLOCKS)));
|
||||
ITEMS.register(blockName, () -> new BlockItem(shiftOnMove.get(), new Item.Properties().tab(ItemGroup.TAB_BUILDING_BLOCKS)));
|
||||
}
|
||||
|
||||
public PistonEventTest()
|
||||
@@ -89,28 +89,28 @@ public class PistonEventTest
|
||||
World world = (World) event.getWorld();
|
||||
PistonBlockStructureHelper pistonHelper = event.getStructureHelper();
|
||||
PlayerEntity player = DistExecutor.safeCallWhenOn(Dist.CLIENT, () -> () -> Minecraft.getInstance().player);
|
||||
if (world.isRemote && player != null)
|
||||
if (world.isClientSide && player != null)
|
||||
{
|
||||
if (pistonHelper.canMove())
|
||||
if (pistonHelper.resolve())
|
||||
{
|
||||
player.sendMessage(new StringTextComponent(String.format("Piston will extend moving %d blocks and destroy %d blocks", pistonHelper.getBlocksToMove().size(), pistonHelper.getBlocksToDestroy().size())), player.getUniqueID());
|
||||
player.sendMessage(new StringTextComponent(String.format("Piston will extend moving %d blocks and destroy %d blocks", pistonHelper.getToPush().size(), pistonHelper.getToDestroy().size())), player.getUUID());
|
||||
}
|
||||
else
|
||||
{
|
||||
player.sendMessage(new StringTextComponent("Piston won't extend"), player.getUniqueID());
|
||||
player.sendMessage(new StringTextComponent("Piston won't extend"), player.getUUID());
|
||||
}
|
||||
}
|
||||
|
||||
if (pistonHelper.canMove())
|
||||
if (pistonHelper.resolve())
|
||||
{
|
||||
List<BlockPos> posList = pistonHelper.getBlocksToMove();
|
||||
List<BlockPos> posList = pistonHelper.getToPush();
|
||||
for (BlockPos newPos : posList)
|
||||
{
|
||||
BlockState state = event.getWorld().getBlockState(newPos);
|
||||
if (state.getBlock() == Blocks.BLACK_WOOL)
|
||||
{
|
||||
Block.spawnDrops(state, world, newPos);
|
||||
world.setBlockState(newPos, Blocks.AIR.getDefaultState());
|
||||
Block.dropResources(state, world, newPos);
|
||||
world.setBlockAndUpdate(newPos, Blocks.AIR.defaultBlockState());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -119,8 +119,8 @@ public class PistonEventTest
|
||||
BlockPos pushedBlockPos = event.getFaceOffsetPos();
|
||||
if (world.getBlockState(pushedBlockPos).getBlock() == shiftOnMove.get() && event.getDirection() != Direction.DOWN)
|
||||
{
|
||||
world.setBlockState(pushedBlockPos, Blocks.AIR.getDefaultState());
|
||||
world.setBlockState(pushedBlockPos.up(), shiftOnMove.get().getDefaultState());
|
||||
world.setBlockAndUpdate(pushedBlockPos, Blocks.AIR.defaultBlockState());
|
||||
world.setBlockAndUpdate(pushedBlockPos.above(), shiftOnMove.get().defaultBlockState());
|
||||
}
|
||||
|
||||
// Block pushing cobblestone (directly, indirectly works)
|
||||
@@ -131,22 +131,22 @@ public class PistonEventTest
|
||||
boolean isSticky = event.getWorld().getBlockState(event.getPos()).getBlock() == Blocks.STICKY_PISTON;
|
||||
|
||||
PlayerEntity player = DistExecutor.safeCallWhenOn(Dist.CLIENT, () -> () -> Minecraft.getInstance().player);
|
||||
if (event.getWorld().isRemote() && player != null)
|
||||
if (event.getWorld().isClientSide() && player != null)
|
||||
{
|
||||
if (isSticky)
|
||||
{
|
||||
BlockPos targetPos = event.getFaceOffsetPos().offset(event.getDirection());
|
||||
boolean canPush = PistonBlock.canPush(event.getWorld().getBlockState(targetPos), (World) event.getWorld(), event.getFaceOffsetPos(), event.getDirection().getOpposite(), false, event.getDirection());
|
||||
boolean isAir = event.getWorld().isAirBlock(targetPos);
|
||||
player.sendMessage(new StringTextComponent(String.format("Piston will retract moving %d blocks", !isAir && canPush ? 1 : 0)), player.getUniqueID());
|
||||
BlockPos targetPos = event.getFaceOffsetPos().relative(event.getDirection());
|
||||
boolean canPush = PistonBlock.isPushable(event.getWorld().getBlockState(targetPos), (World) event.getWorld(), event.getFaceOffsetPos(), event.getDirection().getOpposite(), false, event.getDirection());
|
||||
boolean isAir = event.getWorld().isEmptyBlock(targetPos);
|
||||
player.sendMessage(new StringTextComponent(String.format("Piston will retract moving %d blocks", !isAir && canPush ? 1 : 0)), player.getUUID());
|
||||
}
|
||||
else
|
||||
{
|
||||
player.sendMessage(new StringTextComponent("Piston will retract"), player.getUniqueID());
|
||||
player.sendMessage(new StringTextComponent("Piston will retract"), player.getUUID());
|
||||
}
|
||||
}
|
||||
// Offset twice to see if retraction will pull cobblestone
|
||||
event.setCanceled(event.getWorld().getBlockState(event.getFaceOffsetPos().offset(event.getDirection())).getBlock() == Blocks.COBBLESTONE && isSticky);
|
||||
event.setCanceled(event.getWorld().getBlockState(event.getFaceOffsetPos().relative(event.getDirection())).getBlock() == Blocks.COBBLESTONE && isSticky);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -45,6 +45,8 @@ import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
|
||||
import net.minecraftforge.registries.DeferredRegister;
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
|
||||
import net.minecraft.block.AbstractBlock.Properties;
|
||||
|
||||
/**
|
||||
* This test mod allows a custom scaffolding to move down
|
||||
* while sneaking through a method.
|
||||
@@ -56,7 +58,7 @@ public class ScaffoldingTest
|
||||
static final DeferredRegister<Block> BLOCKS = DeferredRegister.create(ForgeRegistries.BLOCKS, MODID);
|
||||
static final IOptionalNamedTag<Block> SCAFFOLDING = BlockTags.createOptional(new ResourceLocation("forge", "scaffolding"));
|
||||
|
||||
static final RegistryObject<Block> SCAFFOLDING_METHOD_TEST = BLOCKS.register("scaffolding_method_test", () -> new ScaffoldingMethodTestBlock(AbstractBlock.Properties.create(Material.MISCELLANEOUS, MaterialColor.SAND).doesNotBlockMovement().sound(SoundType.SCAFFOLDING).variableOpacity()));
|
||||
static final RegistryObject<Block> SCAFFOLDING_METHOD_TEST = BLOCKS.register("scaffolding_method_test", () -> new ScaffoldingMethodTestBlock(AbstractBlock.Properties.of(Material.DECORATION, MaterialColor.SAND).noCollission().sound(SoundType.SCAFFOLDING).dynamicShape()));
|
||||
|
||||
public ScaffoldingTest()
|
||||
{
|
||||
@@ -81,7 +83,7 @@ public class ScaffoldingTest
|
||||
@Override
|
||||
protected void registerStatesAndModels()
|
||||
{
|
||||
this.getVariantBuilder(SCAFFOLDING_METHOD_TEST.get()).forAllStatesExcept((state) -> ConfiguredModel.builder().modelFile(state.get(ScaffoldingBlock.BOTTOM) ? new ModelFile.ExistingModelFile(new ResourceLocation("block/scaffolding_unstable"), this.models().existingFileHelper) : new ModelFile.ExistingModelFile(new ResourceLocation("block/scaffolding_stable"), this.models().existingFileHelper)).build(), ScaffoldingBlock.DISTANCE, ScaffoldingBlock.WATERLOGGED);
|
||||
this.getVariantBuilder(SCAFFOLDING_METHOD_TEST.get()).forAllStatesExcept((state) -> ConfiguredModel.builder().modelFile(state.getValue(ScaffoldingBlock.BOTTOM) ? new ModelFile.ExistingModelFile(new ResourceLocation("block/scaffolding_unstable"), this.models().existingFileHelper) : new ModelFile.ExistingModelFile(new ResourceLocation("block/scaffolding_stable"), this.models().existingFileHelper)).build(), ScaffoldingBlock.DISTANCE, ScaffoldingBlock.WATERLOGGED);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -47,7 +47,7 @@ public class SlipperinessTest
|
||||
@SubscribeEvent
|
||||
public static void registerBlocks(RegistryEvent.Register<Block> e)
|
||||
{
|
||||
e.getRegistry().register((new Block(Block.Properties.create(Material.PACKED_ICE))
|
||||
e.getRegistry().register((new Block(Block.Properties.of(Material.ICE_SOLID))
|
||||
{
|
||||
@Override
|
||||
public float getSlipperiness(BlockState state, IWorldReader world, BlockPos pos, Entity entity)
|
||||
|
||||
@@ -43,7 +43,7 @@ public class StickyBlockTest
|
||||
@SubscribeEvent
|
||||
public static void registerBlocks(RegistryEvent.Register<Block> event)
|
||||
{
|
||||
event.getRegistry().register((new Block(Block.Properties.create(Material.ROCK))
|
||||
event.getRegistry().register((new Block(Block.Properties.of(Material.STONE))
|
||||
{
|
||||
@Override
|
||||
public boolean isStickyBlock(BlockState state)
|
||||
|
||||
@@ -55,8 +55,8 @@ public class CommandEventTest
|
||||
// test: whenever a player uses the /give command, let everyone on the server know
|
||||
if (nodes.size() > 0 && nodes.get(0).getNode() == dispatcher.getRoot().getChild("give"))
|
||||
{
|
||||
String msg = source.getName() + " used the give command: " + event.getParseResults().getReader().getString();
|
||||
source.getServer().getPlayerList().getPlayers().forEach(player -> player.sendMessage(new StringTextComponent(msg), player.getUniqueID()));
|
||||
String msg = source.getTextName() + " used the give command: " + event.getParseResults().getReader().getString();
|
||||
source.getServer().getPlayerList().getPlayers().forEach(player -> player.sendMessage(new StringTextComponent(msg), player.getUUID()));
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -54,7 +54,7 @@ public class EntitySelectorTest
|
||||
private void healthArgument(EntitySelectorParser parser) throws CommandSyntaxException
|
||||
{
|
||||
MinMaxBounds.FloatBound bound = MinMaxBounds.FloatBound.fromReader(parser.getReader());
|
||||
parser.addFilter(entity -> entity instanceof LivingEntity && bound.test(((LivingEntity) entity).getHealth()));
|
||||
parser.addPredicate(entity -> entity instanceof LivingEntity && bound.matches(((LivingEntity) entity).getHealth()));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -66,25 +66,25 @@ public class EntitySelectorTest
|
||||
@Override
|
||||
public EntitySelector build(EntitySelectorParser parser) throws CommandSyntaxException
|
||||
{
|
||||
parser.setSorter(EntitySelectorParser.RANDOM);
|
||||
parser.setLimit(1);
|
||||
parser.setIncludeNonPlayers(true);
|
||||
parser.addFilter(Entity::isAlive);
|
||||
parser.setSuggestionHandler((builder, consumer) -> builder.suggest(String.valueOf('[')).buildFuture());
|
||||
parser.setOrder(EntitySelectorParser.ORDER_RANDOM);
|
||||
parser.setMaxResults(1);
|
||||
parser.setIncludesEntities(true);
|
||||
parser.addPredicate(Entity::isAlive);
|
||||
parser.setSuggestions((builder, consumer) -> builder.suggest(String.valueOf('[')).buildFuture());
|
||||
if (parser.getReader().canRead() && parser.getReader().peek() == '[')
|
||||
{
|
||||
parser.getReader().skip();
|
||||
parser.setSuggestionHandler((builder, consumer) -> {
|
||||
parser.setSuggestions((builder, consumer) -> {
|
||||
builder.suggest(String.valueOf(']'));
|
||||
EntityOptions.suggestOptions(parser, builder);
|
||||
EntityOptions.suggestNames(parser, builder);
|
||||
return builder.buildFuture();
|
||||
});
|
||||
|
||||
parser.parseArguments();
|
||||
parser.parseOptions();
|
||||
}
|
||||
|
||||
parser.updateFilter();
|
||||
return parser.build();
|
||||
parser.finalizePredicates();
|
||||
return parser.getSelector();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -53,9 +53,9 @@ public class CompositeModelTest
|
||||
public static final DeferredRegister<Item> ITEMS = DeferredRegister.create(ForgeRegistries.ITEMS, MODID);
|
||||
|
||||
public static RegistryObject<Block> composite_block = BLOCKS.register("composite_block", () ->
|
||||
new Block(Block.Properties.create(Material.WOOD).hardnessAndResistance(10)) {
|
||||
new Block(Block.Properties.of(Material.WOOD).strength(10)) {
|
||||
@Override
|
||||
protected void fillStateContainer(StateContainer.Builder<Block, BlockState> builder)
|
||||
protected void createBlockStateDefinition(StateContainer.Builder<Block, BlockState> builder)
|
||||
{
|
||||
builder.add(BlockStateProperties.HORIZONTAL_FACING);
|
||||
}
|
||||
@@ -64,30 +64,30 @@ public class CompositeModelTest
|
||||
@Override
|
||||
public BlockState getStateForPlacement(BlockItemUseContext context)
|
||||
{
|
||||
return getDefaultState().with(
|
||||
BlockStateProperties.HORIZONTAL_FACING, context.getPlacementHorizontalFacing()
|
||||
return defaultBlockState().setValue(
|
||||
BlockStateProperties.HORIZONTAL_FACING, context.getHorizontalDirection()
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) {
|
||||
return VoxelShapes.or(
|
||||
makeCuboidShape(5.6, 5.6, 5.6, 10.4, 10.4, 10.4),
|
||||
makeCuboidShape(0, 0, 0, 4.8, 4.8, 4.8),
|
||||
makeCuboidShape(11.2, 0, 0, 16, 4.8, 4.8),
|
||||
makeCuboidShape(0, 0, 11.2, 4.8, 4.8, 16),
|
||||
makeCuboidShape(11.2, 0, 11.2, 16, 4.8, 16),
|
||||
makeCuboidShape(0, 11.2, 0, 4.8, 16, 4.8),
|
||||
makeCuboidShape(11.2, 11.2, 0, 16, 16, 4.8),
|
||||
makeCuboidShape(0, 11.2, 11.2, 4.8, 16, 16),
|
||||
makeCuboidShape(11.2, 11.2, 11.2, 16, 16, 16)
|
||||
box(5.6, 5.6, 5.6, 10.4, 10.4, 10.4),
|
||||
box(0, 0, 0, 4.8, 4.8, 4.8),
|
||||
box(11.2, 0, 0, 16, 4.8, 4.8),
|
||||
box(0, 0, 11.2, 4.8, 4.8, 16),
|
||||
box(11.2, 0, 11.2, 16, 4.8, 16),
|
||||
box(0, 11.2, 0, 4.8, 16, 4.8),
|
||||
box(11.2, 11.2, 0, 16, 16, 4.8),
|
||||
box(0, 11.2, 11.2, 4.8, 16, 16),
|
||||
box(11.2, 11.2, 11.2, 16, 16, 16)
|
||||
);
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
public static RegistryObject<Item> composite_item = ITEMS.register("composite_block", () ->
|
||||
new BlockItem(composite_block.get(), new Item.Properties().group(ItemGroup.MISC)) {
|
||||
new BlockItem(composite_block.get(), new Item.Properties().tab(ItemGroup.TAB_MISC)) {
|
||||
@Override
|
||||
public boolean canEquip(ItemStack stack, EquipmentSlotType armorType, Entity entity)
|
||||
{
|
||||
|
||||
@@ -15,8 +15,8 @@ public class DynBucketModelTest
|
||||
public static final String MODID = "dyn_bucket_model_test";
|
||||
public static final DeferredRegister<Item> ITEMS = DeferredRegister.create(ForgeRegistries.ITEMS, MODID);
|
||||
|
||||
public static final RegistryObject<Item> DRIP_BUCKET = ITEMS.register("drip_bucket", () -> new Item(new Item.Properties().group(ItemGroup.MISC)));
|
||||
public static final RegistryObject<Item> LAVA_OBSIDIAN = ITEMS.register("lava_obsidian", () -> new Item(new Item.Properties().group(ItemGroup.MISC)));
|
||||
public static final RegistryObject<Item> DRIP_BUCKET = ITEMS.register("drip_bucket", () -> new Item(new Item.Properties().tab(ItemGroup.TAB_MISC)));
|
||||
public static final RegistryObject<Item> LAVA_OBSIDIAN = ITEMS.register("lava_obsidian", () -> new Item(new Item.Properties().tab(ItemGroup.TAB_MISC)));
|
||||
|
||||
public DynBucketModelTest()
|
||||
{
|
||||
|
||||
@@ -53,7 +53,7 @@ public class MultiLayerModelTest
|
||||
if (!ENABLED)
|
||||
return;
|
||||
event.getRegistry().register(
|
||||
new Block(Block.Properties.create(Material.WOOD).notSolid())
|
||||
new Block(Block.Properties.of(Material.WOOD).noOcclusion())
|
||||
{
|
||||
}.setRegistryName(blockId)
|
||||
);
|
||||
@@ -64,7 +64,7 @@ public class MultiLayerModelTest
|
||||
{
|
||||
if (!ENABLED)
|
||||
return;
|
||||
event.getRegistry().register(new BlockItem(TEST_BLOCK, new Item.Properties().group(ItemGroup.MISC)).setRegistryName(TEST_BLOCK.getRegistryName()));
|
||||
event.getRegistry().register(new BlockItem(TEST_BLOCK, new Item.Properties().tab(ItemGroup.TAB_MISC)).setRegistryName(TEST_BLOCK.getRegistryName()));
|
||||
}
|
||||
|
||||
@net.minecraftforge.eventbus.api.SubscribeEvent
|
||||
@@ -73,7 +73,7 @@ public class MultiLayerModelTest
|
||||
if (!ENABLED)
|
||||
return;
|
||||
RenderTypeLookup.setRenderLayer(TEST_BLOCK, (layer) -> {
|
||||
return layer == RenderType.getSolid() || layer == RenderType.getTranslucent();
|
||||
return layer == RenderType.solid() || layer == RenderType.translucent();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -78,9 +78,9 @@ public class NewModelLoaderTest
|
||||
public static final DeferredRegister<Item> ITEMS = DeferredRegister.create(ForgeRegistries.ITEMS, MODID);
|
||||
|
||||
public static RegistryObject<Block> obj_block = BLOCKS.register("obj_block", () ->
|
||||
new Block(Block.Properties.create(Material.WOOD).hardnessAndResistance(10)) {
|
||||
new Block(Block.Properties.of(Material.WOOD).strength(10)) {
|
||||
@Override
|
||||
protected void fillStateContainer(StateContainer.Builder<Block, BlockState> builder)
|
||||
protected void createBlockStateDefinition(StateContainer.Builder<Block, BlockState> builder)
|
||||
{
|
||||
builder.add(BlockStateProperties.HORIZONTAL_FACING);
|
||||
}
|
||||
@@ -89,21 +89,21 @@ public class NewModelLoaderTest
|
||||
@Override
|
||||
public BlockState getStateForPlacement(BlockItemUseContext context)
|
||||
{
|
||||
return getDefaultState().with(
|
||||
BlockStateProperties.HORIZONTAL_FACING, context.getPlacementHorizontalFacing()
|
||||
return defaultBlockState().setValue(
|
||||
BlockStateProperties.HORIZONTAL_FACING, context.getHorizontalDirection()
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context)
|
||||
{
|
||||
return Block.makeCuboidShape(2,2,2,14,14,14);
|
||||
return Block.box(2,2,2,14,14,14);
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
public static RegistryObject<Item> obj_item = ITEMS.register("obj_block", () ->
|
||||
new BlockItem(obj_block.get(), new Item.Properties().group(ItemGroup.MISC)) {
|
||||
new BlockItem(obj_block.get(), new Item.Properties().tab(ItemGroup.TAB_MISC)) {
|
||||
@Override
|
||||
public boolean canEquip(ItemStack stack, EquipmentSlotType armorType, Entity entity)
|
||||
{
|
||||
@@ -113,23 +113,23 @@ public class NewModelLoaderTest
|
||||
);
|
||||
|
||||
public static RegistryObject<Item> custom_transforms = ITEMS.register("custom_transforms", () ->
|
||||
new Item(new Item.Properties().group(ItemGroup.MISC))
|
||||
new Item(new Item.Properties().tab(ItemGroup.TAB_MISC))
|
||||
);
|
||||
|
||||
public static RegistryObject<Item> custom_vanilla_loader = ITEMS.register("custom_vanilla_loader", () ->
|
||||
new Item(new Item.Properties().group(ItemGroup.MISC))
|
||||
new Item(new Item.Properties().tab(ItemGroup.TAB_MISC))
|
||||
);
|
||||
|
||||
public static RegistryObject<Item> custom_loader = ITEMS.register("custom_loader", () ->
|
||||
new Item(new Item.Properties().group(ItemGroup.MISC))
|
||||
new Item(new Item.Properties().tab(ItemGroup.TAB_MISC))
|
||||
);
|
||||
|
||||
public static RegistryObject<Item> item_layers = ITEMS.register("item_layers", () ->
|
||||
new Item(new Item.Properties().group(ItemGroup.MISC))
|
||||
new Item(new Item.Properties().tab(ItemGroup.TAB_MISC))
|
||||
);
|
||||
|
||||
public static RegistryObject<Item> separate_perspective = ITEMS.register("separate_perspective", () ->
|
||||
new Item(new Item.Properties().group(ItemGroup.MISC))
|
||||
new Item(new Item.Properties().tab(ItemGroup.TAB_MISC))
|
||||
);
|
||||
|
||||
public NewModelLoaderTest()
|
||||
@@ -174,10 +174,10 @@ public class NewModelLoaderTest
|
||||
builder.setTexture(texture);
|
||||
builder.setQuadOrientation(Direction.UP);
|
||||
|
||||
putVertex(builder, 0,1,0.5f, texture.getInterpolatedU(0), texture.getInterpolatedV(0), 1, 1, 1);
|
||||
putVertex(builder, 0,0,0.5f, texture.getInterpolatedU(0), texture.getInterpolatedV(16), 1, 1, 1);
|
||||
putVertex(builder, 1,0,0.5f, texture.getInterpolatedU(16), texture.getInterpolatedV(16), 1, 1, 1);
|
||||
putVertex(builder, 1,1,0.5f, texture.getInterpolatedU(16), texture.getInterpolatedV(0), 1, 1, 1);
|
||||
putVertex(builder, 0,1,0.5f, texture.getU(0), texture.getV(0), 1, 1, 1);
|
||||
putVertex(builder, 0,0,0.5f, texture.getU(0), texture.getV(16), 1, 1, 1);
|
||||
putVertex(builder, 1,0,0.5f, texture.getU(16), texture.getV(16), 1, 1, 1);
|
||||
putVertex(builder, 1,1,0.5f, texture.getU(16), texture.getV(0), 1, 1, 1);
|
||||
|
||||
modelBuilder.addGeneralQuad(builder.build());
|
||||
}
|
||||
|
||||
@@ -62,9 +62,9 @@ public class TRSRTransformerTest {
|
||||
private static final DeferredRegister<Block> BLOCKS = DeferredRegister.create(ForgeRegistries.BLOCKS, MODID);
|
||||
private static final DeferredRegister<Item> ITEMS = DeferredRegister.create(ForgeRegistries.ITEMS, MODID);
|
||||
|
||||
private static final RegistryObject<Block> TEST_BLOCK = BLOCKS.register("test", () -> new Block(Block.Properties.create(Material.ROCK)));
|
||||
private static final RegistryObject<Block> TEST_BLOCK = BLOCKS.register("test", () -> new Block(Block.Properties.of(Material.STONE)));
|
||||
@SuppressWarnings("unused")
|
||||
private static final RegistryObject<Item> TEST_ITEM = ITEMS.register("test", () -> new BlockItem(TEST_BLOCK.get(), new Item.Properties().group(ItemGroup.MISC)));
|
||||
private static final RegistryObject<Item> TEST_ITEM = ITEMS.register("test", () -> new BlockItem(TEST_BLOCK.get(), new Item.Properties().tab(ItemGroup.TAB_MISC)));
|
||||
|
||||
public TRSRTransformerTest() {
|
||||
final IEventBus mod = FMLJavaModLoadingContext.get().getModEventBus();
|
||||
@@ -118,8 +118,8 @@ public class TRSRTransformerTest {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAmbientOcclusion() {
|
||||
return base.isAmbientOcclusion();
|
||||
public boolean useAmbientOcclusion() {
|
||||
return base.useAmbientOcclusion();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -128,18 +128,18 @@ public class TRSRTransformerTest {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSideLit() {
|
||||
return base.isSideLit();
|
||||
public boolean usesBlockLight() {
|
||||
return base.usesBlockLight();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBuiltInRenderer() {
|
||||
return base.isBuiltInRenderer();
|
||||
public boolean isCustomRenderer() {
|
||||
return base.isCustomRenderer();
|
||||
}
|
||||
|
||||
@Override
|
||||
public TextureAtlasSprite getParticleTexture() {
|
||||
return base.getParticleTexture();
|
||||
public TextureAtlasSprite getParticleIcon() {
|
||||
return base.getParticleIcon();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+2
-2
@@ -48,13 +48,13 @@ public class NameplateRenderingEventTest
|
||||
|
||||
if(event.getEntity() instanceof CowEntity)
|
||||
{
|
||||
event.setContent(new StringTextComponent("Evil Cow").mergeStyle(TextFormatting.RED));
|
||||
event.setContent(new StringTextComponent("Evil Cow").withStyle(TextFormatting.RED));
|
||||
event.setResult(Event.Result.ALLOW);
|
||||
}
|
||||
|
||||
if(event.getEntity() instanceof PlayerEntity)
|
||||
{
|
||||
event.setContent(event.getEntity().getDisplayName().deepCopy().mergeStyle(TextFormatting.GOLD));
|
||||
event.setContent(event.getEntity().getDisplayName().copy().withStyle(TextFormatting.GOLD));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -40,9 +40,9 @@ public class RenderLocalPlayerTest
|
||||
if (ENABLED && event.getItemStack().getItem() == Items.STICK)
|
||||
{
|
||||
Minecraft mc = Minecraft.getInstance();
|
||||
if (mc.getRenderViewEntity() == mc.player)
|
||||
if (mc.getCameraEntity() == mc.player)
|
||||
{
|
||||
mc.setRenderViewEntity(event.getTarget());
|
||||
mc.setCameraEntity(event.getTarget());
|
||||
|
||||
event.setCancellationResult(ActionResultType.SUCCESS);
|
||||
event.setCanceled(true);
|
||||
@@ -56,9 +56,9 @@ public class RenderLocalPlayerTest
|
||||
if (ENABLED && event.getItemStack().getItem() == Items.STICK)
|
||||
{
|
||||
Minecraft mc = Minecraft.getInstance();
|
||||
if (mc.getRenderViewEntity() != mc.player)
|
||||
if (mc.getCameraEntity() != mc.player)
|
||||
{
|
||||
mc.setRenderViewEntity(mc.player);
|
||||
mc.setCameraEntity(mc.player);
|
||||
|
||||
event.setCancellationResult(ActionResultType.SUCCESS);
|
||||
event.setCanceled(true);
|
||||
|
||||
@@ -36,6 +36,6 @@ public class StencilEnableTest {
|
||||
|
||||
private void clientSetup(FMLClientSetupEvent event) {
|
||||
if (ENABLED)
|
||||
event.enqueueWork(() -> Minecraft.getInstance().getFramebuffer().enableStencil());
|
||||
event.enqueueWork(() -> Minecraft.getInstance().getMainRenderTarget().enableStencil());
|
||||
}
|
||||
}
|
||||
@@ -32,7 +32,7 @@ import net.minecraftforge.registries.DeferredRegister;
|
||||
public class AddEntityAttributeTest {
|
||||
public static final boolean ENABLE = true;
|
||||
private static final DeferredRegister<Attribute> ATTRIBUTES = DeferredRegister.create(Attribute.class, "add_entity_attribute_test");
|
||||
public static final RegistryObject<Attribute> TEST_ATTR = ATTRIBUTES.register("test_attr", () -> new RangedAttribute("forge.test_attr", 1.0D, 0.0D, 1024.0D).setShouldWatch(true));
|
||||
public static final RegistryObject<Attribute> TEST_ATTR = ATTRIBUTES.register("test_attr", () -> new RangedAttribute("forge.test_attr", 1.0D, 0.0D, 1024.0D).setSyncable(true));
|
||||
|
||||
public AddEntityAttributeTest() {
|
||||
if (ENABLE) {
|
||||
|
||||
@@ -52,6 +52,8 @@ import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
|
||||
|
||||
import net.minecraft.item.Item.Properties;
|
||||
|
||||
@Mod("gravity_attribute_test")
|
||||
public class GravityAttributeTest
|
||||
{
|
||||
@@ -74,18 +76,18 @@ public class GravityAttributeTest
|
||||
@SubscribeEvent
|
||||
public void worldTick(TickEvent.WorldTickEvent event)
|
||||
{
|
||||
if (!event.world.isRemote)
|
||||
if (!event.world.isClientSide)
|
||||
{
|
||||
if (ticks++ > 60)
|
||||
{
|
||||
ticks = 0;
|
||||
World w = event.world;
|
||||
List<LivingEntity> list;
|
||||
if(w.isRemote)
|
||||
if(w.isClientSide)
|
||||
{
|
||||
ClientWorld cw = (ClientWorld)w;
|
||||
list = new ArrayList<>(100);
|
||||
for(Entity e : cw.getAllEntities())
|
||||
for(Entity e : cw.entitiesForRendering())
|
||||
{
|
||||
if(e.isAlive() && e instanceof LivingEntity)
|
||||
list.add((LivingEntity)e);
|
||||
@@ -101,11 +103,11 @@ public class GravityAttributeTest
|
||||
for(LivingEntity liv : list)
|
||||
{
|
||||
ModifiableAttributeInstance grav = liv.getAttribute(ForgeMod.ENTITY_GRAVITY.get());
|
||||
boolean inPlains = liv.world.getBiome(liv.getPosition()).getCategory() == Category.PLAINS;
|
||||
boolean inPlains = liv.level.getBiome(liv.blockPosition()).getBiomeCategory() == Category.PLAINS;
|
||||
if (inPlains && !grav.hasModifier(REDUCED_GRAVITY))
|
||||
{
|
||||
logger.info("Granted low gravity to Entity: {}", liv);
|
||||
grav.applyNonPersistentModifier(REDUCED_GRAVITY);
|
||||
grav.addTransientModifier(REDUCED_GRAVITY);
|
||||
}
|
||||
else if (!inPlains && grav.hasModifier(REDUCED_GRAVITY))
|
||||
{
|
||||
@@ -121,7 +123,7 @@ public class GravityAttributeTest
|
||||
@SubscribeEvent
|
||||
public void registerItems(RegistryEvent.Register<Item> event)
|
||||
{
|
||||
event.getRegistry().register(new ItemGravityStick(new Item.Properties().group(ItemGroup.TOOLS).rarity(Rarity.RARE)).setRegistryName("gravity_attribute_test:gravity_stick"));
|
||||
event.getRegistry().register(new ItemGravityStick(new Item.Properties().tab(ItemGroup.TAB_TOOLS).rarity(Rarity.RARE)).setRegistryName("gravity_attribute_test:gravity_stick"));
|
||||
}
|
||||
|
||||
public static class ItemGravityStick extends Item
|
||||
@@ -134,10 +136,10 @@ public class GravityAttributeTest
|
||||
}
|
||||
|
||||
@Override
|
||||
public Multimap<Attribute, AttributeModifier> getAttributeModifiers(EquipmentSlotType slot)
|
||||
public Multimap<Attribute, AttributeModifier> getDefaultAttributeModifiers(EquipmentSlotType slot)
|
||||
{
|
||||
@SuppressWarnings("deprecation")
|
||||
Multimap<Attribute, AttributeModifier> multimap = super.getAttributeModifiers(slot);
|
||||
Multimap<Attribute, AttributeModifier> multimap = super.getDefaultAttributeModifiers(slot);
|
||||
if (slot == EquipmentSlotType.MAINHAND)
|
||||
multimap.put(ForgeMod.ENTITY_GRAVITY.get(), new AttributeModifier(GRAVITY_MODIFIER, "More Gravity", 1.0D, Operation.ADDITION));
|
||||
|
||||
|
||||
@@ -48,6 +48,6 @@ public class LivingConversionEventTest
|
||||
public void onLivingConversion(LivingConversionEvent.Post event)
|
||||
{
|
||||
if (event.getEntityLiving() instanceof VillagerEntity)
|
||||
event.getEntityLiving().addPotionEffect(new EffectInstance(Effects.LUCK, 20));
|
||||
event.getEntityLiving().addEffect(new EffectInstance(Effects.LUCK, 20));
|
||||
}
|
||||
}
|
||||
@@ -48,6 +48,6 @@ public class PlayerGameModeEventTest
|
||||
public static void onClientPlayerChangeGameModeEvent(ClientPlayerChangeGameModeEvent event)
|
||||
{
|
||||
if (!ENABLE) return;
|
||||
LOGGER.info("Client notified of changed game mode from '{}'. Current GameType: {}. New Game Type: {}", event.getInfo().getGameProfile(), event.getCurrentGameMode(), event.getNewGameMode());
|
||||
LOGGER.info("Client notified of changed game mode from '{}'. Current GameType: {}. New Game Type: {}", event.getInfo().getProfile(), event.getCurrentGameMode(), event.getNewGameMode());
|
||||
}
|
||||
}
|
||||
@@ -45,7 +45,7 @@ public class PlayerXpEventTest
|
||||
public static void onPlayerPickupXp(PlayerXpEvent.PickupXp event)
|
||||
{
|
||||
if (!ENABLE) return;
|
||||
logger.info("{} picked up an experience orb worth {}", event.getPlayer().getName().getString(), event.getOrb().getXpValue());
|
||||
logger.info("{} picked up an experience orb worth {}", event.getPlayer().getName().getString(), event.getOrb().getValue());
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
|
||||
@@ -40,11 +40,11 @@ public class FiniteWaterTest
|
||||
{
|
||||
BlockState state = event.getState();
|
||||
FluidState fluidState = state.getFluidState();
|
||||
if (fluidState.getFluid().isEquivalentTo(Fluids.WATER))
|
||||
if (fluidState.getType().isSame(Fluids.WATER))
|
||||
{
|
||||
event.setResult(Event.Result.DENY);
|
||||
}
|
||||
else if (fluidState.getFluid().isEquivalentTo(Fluids.LAVA))
|
||||
else if (fluidState.getType().isSame(Fluids.LAVA))
|
||||
{
|
||||
event.setResult(Event.Result.ALLOW);
|
||||
}
|
||||
|
||||
@@ -48,7 +48,7 @@ public class MilkFluidTest
|
||||
ItemStack stack = event.getItemStack();
|
||||
if (stack.getItem() == Items.MILK_BUCKET)
|
||||
{
|
||||
FluidUtil.getFluidContained(stack).ifPresent((fluid) -> event.getPlayer().sendStatusMessage(new StringTextComponent("Contains ").append(fluid.getDisplayName()), true));
|
||||
FluidUtil.getFluidContained(stack).ifPresent((fluid) -> event.getPlayer().displayClientMessage(new StringTextComponent("Contains ").append(fluid.getDisplayName()), true));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -48,6 +48,8 @@ import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
|
||||
import net.minecraftforge.registries.DeferredRegister;
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
|
||||
import net.minecraft.block.AbstractBlock.Properties;
|
||||
|
||||
@Mod(NewFluidTest.MODID)
|
||||
public class NewFluidTest
|
||||
{
|
||||
@@ -76,18 +78,18 @@ public class NewFluidTest
|
||||
);
|
||||
|
||||
public static RegistryObject<FlowingFluidBlock> test_fluid_block = BLOCKS.register("test_fluid_block", () ->
|
||||
new FlowingFluidBlock(test_fluid, Block.Properties.create(net.minecraft.block.material.Material.WATER).doesNotBlockMovement().hardnessAndResistance(100.0F).noDrops())
|
||||
new FlowingFluidBlock(test_fluid, Block.Properties.of(net.minecraft.block.material.Material.WATER).noCollission().strength(100.0F).noDrops())
|
||||
);
|
||||
public static RegistryObject<Item> test_fluid_bucket = ITEMS.register("test_fluid_bucket", () ->
|
||||
new BucketItem(test_fluid, new Item.Properties().containerItem(Items.BUCKET).maxStackSize(1).group(ItemGroup.MISC))
|
||||
new BucketItem(test_fluid, new Item.Properties().craftRemainder(Items.BUCKET).stacksTo(1).tab(ItemGroup.TAB_MISC))
|
||||
);
|
||||
|
||||
// WARNING: this doesn't allow "any fluid", only the fluid from this test mod!
|
||||
public static RegistryObject<Block> fluidloggable_block = BLOCKS.register("fluidloggable_block", () ->
|
||||
new FluidloggableBlock(Block.Properties.create(Material.WOOD).doesNotBlockMovement().hardnessAndResistance(100.0F).noDrops())
|
||||
new FluidloggableBlock(Block.Properties.of(Material.WOOD).noCollission().strength(100.0F).noDrops())
|
||||
);
|
||||
public static RegistryObject<Item> fluidloggable_blockitem = ITEMS.register("fluidloggable_block", () ->
|
||||
new BlockItem(fluidloggable_block.get(), new Item.Properties().group(ItemGroup.MISC))
|
||||
new BlockItem(fluidloggable_block.get(), new Item.Properties().tab(ItemGroup.TAB_MISC))
|
||||
);
|
||||
|
||||
public NewFluidTest()
|
||||
@@ -104,12 +106,12 @@ public class NewFluidTest
|
||||
public void loadComplete(FMLLoadCompleteEvent event)
|
||||
{
|
||||
// some sanity checks
|
||||
BlockState state = Fluids.WATER.getDefaultState().getBlockState();
|
||||
BlockState state2 = Fluids.WATER.getAttributes().getBlock(null,null,Fluids.WATER.getDefaultState());
|
||||
BlockState state = Fluids.WATER.defaultFluidState().createLegacyBlock();
|
||||
BlockState state2 = Fluids.WATER.getAttributes().getBlock(null,null,Fluids.WATER.defaultFluidState());
|
||||
Validate.isTrue(state.getBlock() == Blocks.WATER && state2 == state);
|
||||
ItemStack stack = Fluids.WATER.getAttributes().getBucket(new FluidStack(Fluids.WATER, 1));
|
||||
Validate.isTrue(stack.getItem() == Fluids.WATER.getFilledBucket());
|
||||
event.enqueueWork(() -> DispenserBlock.registerDispenseBehavior(test_fluid_bucket.get(), DispenseFluidContainer.getInstance()));
|
||||
Validate.isTrue(stack.getItem() == Fluids.WATER.getBucket());
|
||||
event.enqueueWork(() -> DispenserBlock.registerBehavior(test_fluid_bucket.get(), DispenseFluidContainer.getInstance()));
|
||||
}
|
||||
|
||||
// WARNING: this doesn't allow "any fluid", only the fluid from this test mod!
|
||||
@@ -120,26 +122,26 @@ public class NewFluidTest
|
||||
public FluidloggableBlock(Properties properties)
|
||||
{
|
||||
super(properties);
|
||||
setDefaultState(getStateContainer().getBaseState().with(FLUIDLOGGED, false));
|
||||
registerDefaultState(getStateDefinition().any().setValue(FLUIDLOGGED, false));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void fillStateContainer(StateContainer.Builder<Block, BlockState> builder)
|
||||
protected void createBlockStateDefinition(StateContainer.Builder<Block, BlockState> builder)
|
||||
{
|
||||
builder.add(FLUIDLOGGED);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canContainFluid(IBlockReader worldIn, BlockPos pos, BlockState state, Fluid fluidIn) {
|
||||
return !state.get(FLUIDLOGGED) && fluidIn == test_fluid.get();
|
||||
public boolean canPlaceLiquid(IBlockReader worldIn, BlockPos pos, BlockState state, Fluid fluidIn) {
|
||||
return !state.getValue(FLUIDLOGGED) && fluidIn == test_fluid.get();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean receiveFluid(IWorld worldIn, BlockPos pos, BlockState state, FluidState fluidStateIn) {
|
||||
if (canContainFluid(worldIn, pos, state, fluidStateIn.getFluid())) {
|
||||
if (!worldIn.isRemote()) {
|
||||
worldIn.setBlockState(pos, state.with(FLUIDLOGGED, true), 3);
|
||||
worldIn.getPendingFluidTicks().scheduleTick(pos, fluidStateIn.getFluid(), fluidStateIn.getFluid().getTickRate(worldIn));
|
||||
public boolean placeLiquid(IWorld worldIn, BlockPos pos, BlockState state, FluidState fluidStateIn) {
|
||||
if (canPlaceLiquid(worldIn, pos, state, fluidStateIn.getType())) {
|
||||
if (!worldIn.isClientSide()) {
|
||||
worldIn.setBlock(pos, state.setValue(FLUIDLOGGED, true), 3);
|
||||
worldIn.getLiquidTicks().scheduleTick(pos, fluidStateIn.getType(), fluidStateIn.getType().getTickDelay(worldIn));
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -149,9 +151,9 @@ public class NewFluidTest
|
||||
}
|
||||
|
||||
@Override
|
||||
public Fluid pickupFluid(IWorld worldIn, BlockPos pos, BlockState state) {
|
||||
if (state.get(FLUIDLOGGED)) {
|
||||
worldIn.setBlockState(pos, state.with(FLUIDLOGGED, false), 3);
|
||||
public Fluid takeLiquid(IWorld worldIn, BlockPos pos, BlockState state) {
|
||||
if (state.getValue(FLUIDLOGGED)) {
|
||||
worldIn.setBlock(pos, state.setValue(FLUIDLOGGED, false), 3);
|
||||
return test_fluid.get();
|
||||
} else {
|
||||
return Fluids.EMPTY;
|
||||
@@ -161,7 +163,7 @@ public class NewFluidTest
|
||||
@Override
|
||||
public FluidState getFluidState(BlockState state)
|
||||
{
|
||||
return state.get(FLUIDLOGGED) ? test_fluid.get().getDefaultState() : Fluids.EMPTY.getDefaultState();
|
||||
return state.getValue(FLUIDLOGGED) ? test_fluid.get().defaultFluidState() : Fluids.EMPTY.defaultFluidState();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -112,8 +112,8 @@ public class GlobalLootModifiersTest {
|
||||
{
|
||||
add("smelting", SMELTING.get(), new SmeltingEnchantmentModifier(
|
||||
new ILootCondition[]{
|
||||
MatchTool.builder(
|
||||
ItemPredicate.Builder.create().enchantment(
|
||||
MatchTool.toolMatches(
|
||||
ItemPredicate.Builder.item().hasEnchantment(
|
||||
new EnchantmentPredicate(SMELT.get(), MinMaxBounds.IntBound.atLeast(1))))
|
||||
.build()
|
||||
})
|
||||
@@ -121,8 +121,8 @@ public class GlobalLootModifiersTest {
|
||||
|
||||
add("wheat_harvest", WHEATSEEDS.get(), new WheatSeedsConverterModifier(
|
||||
new ILootCondition[] {
|
||||
MatchTool.builder(ItemPredicate.Builder.create().item(Items.SHEARS)).build(),
|
||||
BlockStateProperty.builder(Blocks.WHEAT).build()
|
||||
MatchTool.toolMatches(ItemPredicate.Builder.item().of(Items.SHEARS)).build(),
|
||||
BlockStateProperty.hasBlockStateProperties(Blocks.WHEAT).build()
|
||||
},
|
||||
3, Items.WHEAT_SEEDS, Items.WHEAT)
|
||||
);
|
||||
@@ -157,8 +157,8 @@ public class GlobalLootModifiersTest {
|
||||
}
|
||||
|
||||
private static ItemStack smelt(ItemStack stack, LootContext context) {
|
||||
return context.getWorld().getRecipeManager().getRecipe(IRecipeType.SMELTING, new Inventory(stack), context.getWorld())
|
||||
.map(FurnaceRecipe::getRecipeOutput)
|
||||
return context.getLevel().getRecipeManager().getRecipeFor(IRecipeType.SMELTING, new Inventory(stack), context.getLevel())
|
||||
.map(FurnaceRecipe::getResultItem)
|
||||
.filter(itemStack -> !itemStack.isEmpty())
|
||||
.map(itemStack -> ItemHandlerHelper.copyStackWithSize(itemStack, stack.getCount() * itemStack.getCount()))
|
||||
.orElse(stack);
|
||||
@@ -189,16 +189,16 @@ public class GlobalLootModifiersTest {
|
||||
@Nonnull
|
||||
@Override
|
||||
public List<ItemStack> doApply(List<ItemStack> generatedLoot, LootContext context) {
|
||||
ItemStack ctxTool = context.get(LootParameters.TOOL);
|
||||
ItemStack ctxTool = context.getParamOrNull(LootParameters.TOOL);
|
||||
//return early if silk-touch is already applied (otherwise we'll get stuck in an infinite loop).
|
||||
if(EnchantmentHelper.getEnchantments(ctxTool).containsKey(Enchantments.SILK_TOUCH)) return generatedLoot;
|
||||
ItemStack fakeTool = ctxTool.copy();
|
||||
fakeTool.addEnchantment(Enchantments.SILK_TOUCH, 1);
|
||||
fakeTool.enchant(Enchantments.SILK_TOUCH, 1);
|
||||
LootContext.Builder builder = new LootContext.Builder(context);
|
||||
builder.withParameter(LootParameters.TOOL, fakeTool);
|
||||
LootContext ctx = builder.build(LootParameterSets.BLOCK);
|
||||
LootTable loottable = context.getWorld().getServer().getLootTableManager().getLootTableFromLocation(context.get(LootParameters.BLOCK_STATE).getBlock().getLootTable());
|
||||
return loottable.generate(ctx);
|
||||
LootContext ctx = builder.create(LootParameterSets.BLOCK);
|
||||
LootTable loottable = context.getLevel().getServer().getLootTables().get(context.getParamOrNull(LootParameters.BLOCK_STATE).getBlock().getLootTable());
|
||||
return loottable.getRandomItems(ctx);
|
||||
}
|
||||
|
||||
private static class Serializer extends GlobalLootModifierSerializer<SilkTouchTestModifier> {
|
||||
@@ -256,9 +256,9 @@ public class GlobalLootModifiersTest {
|
||||
|
||||
@Override
|
||||
public WheatSeedsConverterModifier read(ResourceLocation name, JsonObject object, ILootCondition[] conditionsIn) {
|
||||
int numSeeds = JSONUtils.getInt(object, "numSeeds");
|
||||
Item seed = ForgeRegistries.ITEMS.getValue(new ResourceLocation((JSONUtils.getString(object, "seedItem"))));
|
||||
Item wheat = ForgeRegistries.ITEMS.getValue(new ResourceLocation(JSONUtils.getString(object, "replacement")));
|
||||
int numSeeds = JSONUtils.getAsInt(object, "numSeeds");
|
||||
Item seed = ForgeRegistries.ITEMS.getValue(new ResourceLocation((JSONUtils.getAsString(object, "seedItem"))));
|
||||
Item wheat = ForgeRegistries.ITEMS.getValue(new ResourceLocation(JSONUtils.getAsString(object, "replacement")));
|
||||
return new WheatSeedsConverterModifier(conditionsIn, numSeeds, seed, wheat);
|
||||
}
|
||||
|
||||
@@ -296,7 +296,7 @@ public class GlobalLootModifiersTest {
|
||||
private static class Serializer extends GlobalLootModifierSerializer<DungeonLootEnhancerModifier> {
|
||||
@Override
|
||||
public DungeonLootEnhancerModifier read(ResourceLocation location, JsonObject object, ILootCondition[] conditions) {
|
||||
final int multiplicationFactor = JSONUtils.getInt(object, "multiplication_factor", 2);
|
||||
final int multiplicationFactor = JSONUtils.getAsInt(object, "multiplication_factor", 2);
|
||||
if (multiplicationFactor <= 0) throw new JsonParseException("Unable to set a multiplication factor to a number lower than 1");
|
||||
return new DungeonLootEnhancerModifier(conditions, multiplicationFactor);
|
||||
}
|
||||
|
||||
@@ -41,13 +41,15 @@ import net.minecraftforge.registries.ForgeRegistries;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import net.minecraft.item.Item.Properties;
|
||||
|
||||
@Mod(CustomElytraTest.MOD_ID)
|
||||
@Mod.EventBusSubscriber(bus = Mod.EventBusSubscriber.Bus.MOD, modid = CustomElytraTest.MOD_ID)
|
||||
public class CustomElytraTest
|
||||
{
|
||||
public static final String MOD_ID = "custom_elytra_test";
|
||||
private static final DeferredRegister<Item> ITEMS = DeferredRegister.create(ForgeRegistries.ITEMS, MOD_ID);
|
||||
private static final RegistryObject<Item> TEST_ELYTRA = ITEMS.register("test_elytra",() -> new CustomElytra(new Item.Properties().maxDamage(100).group(ItemGroup.MISC)));
|
||||
private static final RegistryObject<Item> TEST_ELYTRA = ITEMS.register("test_elytra",() -> new CustomElytra(new Item.Properties().durability(100).tab(ItemGroup.TAB_MISC)));
|
||||
|
||||
public CustomElytraTest()
|
||||
{
|
||||
@@ -64,7 +66,7 @@ public class CustomElytraTest
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
private void registerElytraLayer()
|
||||
{
|
||||
Minecraft.getInstance().getRenderManager().getSkinMap().values().forEach(player -> player.addLayer(new CustomElytraLayer(player)));
|
||||
Minecraft.getInstance().getEntityRenderDispatcher().getSkinMap().values().forEach(player -> player.addLayer(new CustomElytraLayer(player)));
|
||||
}
|
||||
|
||||
public static class CustomElytra extends Item
|
||||
@@ -73,7 +75,7 @@ public class CustomElytraTest
|
||||
public CustomElytra(Properties properties)
|
||||
{
|
||||
super(properties);
|
||||
DispenserBlock.registerDispenseBehavior(this, ArmorItem.DISPENSER_BEHAVIOR);
|
||||
DispenserBlock.registerBehavior(this, ArmorItem.DISPENSE_ITEM_BEHAVIOR);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@@ -93,9 +95,9 @@ public class CustomElytraTest
|
||||
public boolean elytraFlightTick(ItemStack stack, LivingEntity entity, int flightTicks)
|
||||
{
|
||||
//Adding 1 to ticksElytraFlying prevents damage on the very first tick.
|
||||
if (!entity.world.isRemote && (flightTicks + 1) % 20 == 0)
|
||||
if (!entity.level.isClientSide && (flightTicks + 1) % 20 == 0)
|
||||
{
|
||||
stack.damageItem(1, entity, e -> e.sendBreakAnimation(EquipmentSlotType.CHEST));
|
||||
stack.hurtAndBreak(1, entity, e -> e.broadcastBreakEvent(EquipmentSlotType.CHEST));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -37,7 +37,7 @@ public class EnderMaskTest
|
||||
public static final DeferredRegister<Item> ITEMS = DeferredRegister.create(ForgeRegistries.ITEMS, MODID);
|
||||
|
||||
public static RegistryObject<Item> ender_mask = ITEMS.register("ender_mask", () ->
|
||||
new ArmorItem(ArmorMaterial.LEATHER, EquipmentSlotType.HEAD, (new Item.Properties().group(ItemGroup.MISC)))
|
||||
new ArmorItem(ArmorMaterial.LEATHER, EquipmentSlotType.HEAD, (new Item.Properties().tab(ItemGroup.TAB_MISC)))
|
||||
{
|
||||
@Override
|
||||
public boolean isEnderMask(ItemStack stack, PlayerEntity player, EndermanEntity endermanEntity)
|
||||
|
||||
@@ -44,7 +44,7 @@ public class MusicDiscTest
|
||||
() -> new SoundEvent(new ResourceLocation(MOD_ID, "test_sound_event")));
|
||||
|
||||
private static final RegistryObject<Item> TEST_MUSIC_DISC = ITEMS.register("test_music_disc",
|
||||
() -> new MusicDiscItem(1, TEST_SOUND_EVENT, new Item.Properties().maxStackSize(1).rarity(Rarity.EPIC)));
|
||||
() -> new MusicDiscItem(1, TEST_SOUND_EVENT, new Item.Properties().stacksTo(1).rarity(Rarity.EPIC)));
|
||||
|
||||
public MusicDiscTest()
|
||||
{
|
||||
|
||||
@@ -58,7 +58,7 @@ public class ContainerTypeTest
|
||||
|
||||
protected TestContainer(int windowId, PlayerInventory playerInv, PacketBuffer extraData)
|
||||
{
|
||||
this(windowId, new Inventory(9), extraData.readString(128));
|
||||
this(windowId, new Inventory(9), extraData.readUtf(128));
|
||||
}
|
||||
|
||||
public TestContainer(int windowId, Inventory inv, String text)
|
||||
@@ -72,7 +72,7 @@ public class ContainerTypeTest
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInteractWith(PlayerEntity playerIn)
|
||||
public boolean stillValid(PlayerEntity playerIn)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@@ -86,9 +86,9 @@ public class ContainerTypeTest
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerBackgroundLayer(MatrixStack mStack, float partialTicks, int mouseX, int mouseY)
|
||||
protected void renderBg(MatrixStack mStack, float partialTicks, int mouseX, int mouseY)
|
||||
{
|
||||
drawString(mStack, this.font, getContainer().text, mouseX, mouseY, -1);
|
||||
drawString(mStack, this.font, getMenu().text, mouseX, mouseY, -1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -106,12 +106,12 @@ public class ContainerTypeTest
|
||||
|
||||
private void setup(FMLClientSetupEvent event)
|
||||
{
|
||||
ScreenManager.registerFactory(TYPE, TestGui::new);
|
||||
ScreenManager.register(TYPE, TestGui::new);
|
||||
}
|
||||
|
||||
private void onRightClick(PlayerInteractEvent.RightClickBlock event)
|
||||
{
|
||||
if (!event.getWorld().isRemote && event.getHand() == Hand.MAIN_HAND)
|
||||
if (!event.getWorld().isClientSide && event.getHand() == Hand.MAIN_HAND)
|
||||
{
|
||||
if (event.getWorld().getBlockState(event.getPos()).getBlock() == Blocks.SPONGE)
|
||||
{
|
||||
@@ -122,9 +122,9 @@ public class ContainerTypeTest
|
||||
public Container createMenu(int p_createMenu_1_, PlayerInventory p_createMenu_2_, PlayerEntity p_createMenu_3_)
|
||||
{
|
||||
Inventory inv = new Inventory(9);
|
||||
for (int i = 0; i < inv.getSizeInventory(); i++)
|
||||
for (int i = 0; i < inv.getContainerSize(); i++)
|
||||
{
|
||||
inv.setInventorySlotContents(i, new ItemStack(Items.DIAMOND));
|
||||
inv.setItem(i, new ItemStack(Items.DIAMOND));
|
||||
}
|
||||
return new TestContainer(p_createMenu_1_, inv, text);
|
||||
}
|
||||
@@ -135,7 +135,7 @@ public class ContainerTypeTest
|
||||
return new StringTextComponent("Test");
|
||||
}
|
||||
}, extraData -> {
|
||||
extraData.writeString(text);
|
||||
extraData.writeUtf(text);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -101,10 +101,10 @@ public class CustomTagTypesTest
|
||||
ItemStack itemStack = event.getItemStack();
|
||||
if (!itemStack.isEmpty())
|
||||
{
|
||||
LOGGER.info("{} {} {}", Items.BONE.getTags(), OPTIONAL_TEST.getAllElements().size(), TagCollectionManager.getManager().getItemTags().get(new ResourceLocation(MODID, "optional_test")));
|
||||
LOGGER.info("{} {} {}", Items.BONE.getTags(), OPTIONAL_TEST.getValues().size(), TagCollectionManager.getInstance().getItems().getTag(new ResourceLocation(MODID, "optional_test")));
|
||||
EnchantmentHelper.getEnchantments(itemStack).forEach((enchantment, level) -> logTagsIfPresent(enchantment.getTags()));
|
||||
if (itemStack.getItem() instanceof PotionItem) logTagsIfPresent(PotionUtils.getPotionFromItem(itemStack).getTags());
|
||||
TileEntity tileEntity = event.getWorld().getTileEntity(event.getPos());
|
||||
if (itemStack.getItem() instanceof PotionItem) logTagsIfPresent(PotionUtils.getPotion(itemStack).getTags());
|
||||
TileEntity tileEntity = event.getWorld().getBlockEntity(event.getPos());
|
||||
if (tileEntity != null) logTagsIfPresent(tileEntity.getType().getTags());
|
||||
}
|
||||
}
|
||||
@@ -119,7 +119,7 @@ public class CustomTagTypesTest
|
||||
|
||||
public static class Custom extends ForgeRegistryEntry<Custom>
|
||||
{
|
||||
private final ReverseTagWrapper<Custom> reverseTags = new ReverseTagWrapper<>(this, () -> TagCollectionManager.getManager().getCustomTypeCollection(CUSTOM_REG.get()));
|
||||
private final ReverseTagWrapper<Custom> reverseTags = new ReverseTagWrapper<>(this, () -> TagCollectionManager.getInstance().getCustomTypeCollection(CUSTOM_REG.get()));
|
||||
|
||||
public Set<ResourceLocation> getTags()
|
||||
{
|
||||
@@ -140,9 +140,9 @@ public class CustomTagTypesTest
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void registerTags()
|
||||
protected void addTags()
|
||||
{
|
||||
getOrCreateBuilder(TESTS).addItemEntry(CUSTOM.get());
|
||||
tag(TESTS).add(CUSTOM.get());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -160,9 +160,9 @@ public class CustomTagTypesTest
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void registerTags()
|
||||
protected void addTags()
|
||||
{
|
||||
getOrCreateBuilder(FIRE).add(Enchantments.FIRE_ASPECT, Enchantments.FLAME);
|
||||
tag(FIRE).add(Enchantments.FIRE_ASPECT, Enchantments.FLAMING_ARROWS);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -180,9 +180,9 @@ public class CustomTagTypesTest
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void registerTags()
|
||||
protected void addTags()
|
||||
{
|
||||
getOrCreateBuilder(DAMAGE).add(Potions.HARMING, Potions.STRONG_HARMING);
|
||||
tag(DAMAGE).add(Potions.HARMING, Potions.STRONG_HARMING);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -200,9 +200,9 @@ public class CustomTagTypesTest
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void registerTags()
|
||||
protected void addTags()
|
||||
{
|
||||
getOrCreateBuilder(STORAGE).add(TileEntityType.BARREL, TileEntityType.CHEST, TileEntityType.ENDER_CHEST);
|
||||
tag(STORAGE).add(TileEntityType.BARREL, TileEntityType.CHEST, TileEntityType.ENDER_CHEST);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -55,28 +55,28 @@ public class ChunkWatchEventTest
|
||||
@SubscribeEvent
|
||||
public static void onUnwatch(ChunkWatchEvent.UnWatch event)
|
||||
{
|
||||
int watched = watchedByPlayer.getInt(event.getPlayer().getUniqueID());
|
||||
int watched = watchedByPlayer.getInt(event.getPlayer().getUUID());
|
||||
--watched;
|
||||
watchedByPlayer.put(event.getPlayer().getUniqueID(), watched);
|
||||
watchedByPlayer.put(event.getPlayer().getUUID(), watched);
|
||||
logger.info("Unwatching chunk {} in dimension {}. Player's dimension: {}, total chunks watched by player {}",
|
||||
event.getPos(), getDimensionName(event.getWorld()), getDimensionName(event.getPlayer().getEntityWorld()),
|
||||
event.getPos(), getDimensionName(event.getWorld()), getDimensionName(event.getPlayer().getCommandSenderWorld()),
|
||||
watched);
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public static void onWatch(ChunkWatchEvent.Watch event)
|
||||
{
|
||||
int watched = watchedByPlayer.getInt(event.getPlayer().getUniqueID());
|
||||
int watched = watchedByPlayer.getInt(event.getPlayer().getUUID());
|
||||
++watched;
|
||||
watchedByPlayer.put(event.getPlayer().getUniqueID(), watched);
|
||||
watchedByPlayer.put(event.getPlayer().getUUID(), watched);
|
||||
logger.info("Watching chunk {} in dimension {}. Player's dimension: {}, total chunks watched by player {}",
|
||||
event.getPos(), getDimensionName(event.getWorld()), getDimensionName(event.getPlayer().getEntityWorld()),
|
||||
event.getPos(), getDimensionName(event.getWorld()), getDimensionName(event.getPlayer().getCommandSenderWorld()),
|
||||
watched);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static ResourceLocation getDimensionName(World w)
|
||||
{
|
||||
return w.getDimensionKey().getLocation();
|
||||
return w.dimension().location();
|
||||
}
|
||||
}
|
||||
@@ -45,6 +45,8 @@ import net.minecraftforge.registries.ForgeRegistries;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
import net.minecraft.block.AbstractBlock.Properties;
|
||||
|
||||
@Mod(ForgeChunkManagerTest.MODID)
|
||||
public class ForgeChunkManagerTest
|
||||
{
|
||||
@@ -52,8 +54,8 @@ public class ForgeChunkManagerTest
|
||||
private static final Logger LOGGER = LogManager.getLogger(MODID);
|
||||
private static final DeferredRegister<Block> BLOCKS = DeferredRegister.create(ForgeRegistries.BLOCKS, MODID);
|
||||
private static final DeferredRegister<Item> ITEMS = DeferredRegister.create(ForgeRegistries.ITEMS, MODID);
|
||||
private static final RegistryObject<Block> CHUNK_LOADER_BLOCK = BLOCKS.register("chunk_loader", () -> new ChunkLoaderBlock(AbstractBlock.Properties.create(Material.ROCK)));
|
||||
private static final RegistryObject<Item> CHUNK_LOADER_ITEM = ITEMS.register("chunk_loader", () -> new BlockItem(CHUNK_LOADER_BLOCK.get(), new Item.Properties().group(ItemGroup.MISC)));
|
||||
private static final RegistryObject<Block> CHUNK_LOADER_BLOCK = BLOCKS.register("chunk_loader", () -> new ChunkLoaderBlock(AbstractBlock.Properties.of(Material.STONE)));
|
||||
private static final RegistryObject<Item> CHUNK_LOADER_ITEM = ITEMS.register("chunk_loader", () -> new BlockItem(CHUNK_LOADER_BLOCK.get(), new Item.Properties().tab(ItemGroup.TAB_MISC)));
|
||||
|
||||
public ForgeChunkManagerTest()
|
||||
{
|
||||
@@ -71,7 +73,7 @@ public class ForgeChunkManagerTest
|
||||
BlockPos key = entry.getKey();
|
||||
int ticketCount = entry.getValue().getFirst().size();
|
||||
int tickingTicketCount = entry.getValue().getSecond().size();
|
||||
if (world.getBlockState(key).isIn(CHUNK_LOADER_BLOCK.get()))
|
||||
if (world.getBlockState(key).is(CHUNK_LOADER_BLOCK.get()))
|
||||
LOGGER.info("Allowing {} chunk tickets and {} ticking chunk tickets to be reinstated for position: {}.", ticketCount, tickingTicketCount, key);
|
||||
else
|
||||
{
|
||||
@@ -98,9 +100,9 @@ public class ForgeChunkManagerTest
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBlockAdded(BlockState state, World worldIn, BlockPos pos, BlockState oldState, boolean isMoving)
|
||||
public void onPlace(BlockState state, World worldIn, BlockPos pos, BlockState oldState, boolean isMoving)
|
||||
{
|
||||
super.onBlockAdded(state, worldIn, pos, oldState, isMoving);
|
||||
super.onPlace(state, worldIn, pos, oldState, isMoving);
|
||||
if (worldIn instanceof ServerWorld)
|
||||
{
|
||||
ChunkPos chunkPos = new ChunkPos(pos);
|
||||
@@ -109,10 +111,10 @@ public class ForgeChunkManagerTest
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public void onReplaced(BlockState state, World worldIn, BlockPos pos, BlockState newState, boolean isMoving)
|
||||
public void onRemove(BlockState state, World worldIn, BlockPos pos, BlockState newState, boolean isMoving)
|
||||
{
|
||||
super.onReplaced(state, worldIn, pos, newState, isMoving);
|
||||
if (worldIn instanceof ServerWorld && !state.isIn(newState.getBlock()))
|
||||
super.onRemove(state, worldIn, pos, newState, isMoving);
|
||||
if (worldIn instanceof ServerWorld && !state.is(newState.getBlock()))
|
||||
{
|
||||
ChunkPos chunkPos = new ChunkPos(pos);
|
||||
ForgeChunkManager.forceChunk((ServerWorld) worldIn, MODID, pos, chunkPos.x, chunkPos.z, false, false);
|
||||
|
||||
@@ -52,7 +52,7 @@ public class ForgeWorldTypeTest
|
||||
private void registerWorldTypes(RegistryEvent.Register<ForgeWorldType> event)
|
||||
{
|
||||
event.getRegistry().registerAll(
|
||||
new ForgeWorldType(DimensionGeneratorSettings::func_242750_a).setRegistryName("test_world_type")
|
||||
new ForgeWorldType(DimensionGeneratorSettings::makeDefaultOverworld).setRegistryName("test_world_type")
|
||||
);
|
||||
event.getRegistry().registerAll(
|
||||
new ForgeWorldType(this::createChunkGenerator).setRegistryName("test_world_type2")
|
||||
@@ -61,7 +61,7 @@ public class ForgeWorldTypeTest
|
||||
|
||||
private ChunkGenerator createChunkGenerator(Registry<Biome> biomes, Registry<DimensionSettings> dimensionSettings, long seed, String settings)
|
||||
{
|
||||
return DimensionGeneratorSettings.func_242750_a(biomes, dimensionSettings, seed);
|
||||
return DimensionGeneratorSettings.makeDefaultOverworld(biomes, dimensionSettings, seed);
|
||||
}
|
||||
|
||||
private void registerWorldTypeScreenFactories(FMLClientSetupEvent event)
|
||||
@@ -74,7 +74,7 @@ public class ForgeWorldTypeTest
|
||||
super.init();
|
||||
|
||||
addButton(new Button(0, 0, 120, 20, new StringTextComponent("close"), btn -> {
|
||||
Minecraft.getInstance().displayGuiScreen(returnTo);
|
||||
Minecraft.getInstance().setScreen(returnTo);
|
||||
}));
|
||||
}
|
||||
});
|
||||
|
||||
@@ -17,9 +17,9 @@ import net.minecraftforge.registries.ForgeRegistries;
|
||||
public class WorldgenRegistryDesyncTest {
|
||||
|
||||
public static final DeferredRegister<Feature<?>> FEATURES = DeferredRegister.create(ForgeRegistries.FEATURES, "worldgen_registry_desync_test");
|
||||
public static final RegistryObject<Feature<NoFeatureConfig>> dungeon = FEATURES.register("dungeon", () -> new DungeonsFeature(NoFeatureConfig.field_236558_a_));
|
||||
public static final RegistryObject<Feature<NoFeatureConfig>> dungeon = FEATURES.register("dungeon", () -> new DungeonsFeature(NoFeatureConfig.CODEC));
|
||||
public static final DeferredRegister<Biome> BIOMES = DeferredRegister.create(ForgeRegistries.BIOMES, "worldgen_registry_desync_test");
|
||||
public static final RegistryObject<Biome> biome = BIOMES.register("biome", BiomeMaker::makeVoidBiome);
|
||||
public static final RegistryObject<Biome> biome = BIOMES.register("biome", BiomeMaker::theVoidBiome);
|
||||
|
||||
public WorldgenRegistryDesyncTest()
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user