mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-25 06:24:43 +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
@@ -372,7 +372,7 @@ public class BiomeDictionary
|
||||
Type.byName.forEach((name, type) ->
|
||||
buf.append(" ").append(type.name).append(": ")
|
||||
.append(type.biomes.stream()
|
||||
.map(RegistryKey::getLocation)
|
||||
.map(RegistryKey::location)
|
||||
.sorted((a,b) -> a.compareNamespaced(b))
|
||||
.map(Object::toString)
|
||||
.collect(Collectors.joining(", "))
|
||||
@@ -382,7 +382,7 @@ public class BiomeDictionary
|
||||
|
||||
boolean missing = false;
|
||||
List<RegistryKey<Biome>> all = StreamSupport.stream(ForgeRegistries.BIOMES.spliterator(), false)
|
||||
.map(b -> RegistryKey.getOrCreateKey(Registry.BIOME_KEY, b.getRegistryName()))
|
||||
.map(b -> RegistryKey.create(Registry.BIOME_REGISTRY, b.getRegistryName()))
|
||||
.sorted().collect(Collectors.toList());
|
||||
|
||||
for (RegistryKey<Biome> key : all) {
|
||||
@@ -391,7 +391,7 @@ public class BiomeDictionary
|
||||
buf.append("Missing:\n");
|
||||
missing = true;
|
||||
}
|
||||
buf.append(" ").append(key.getLocation()).append('\n');
|
||||
buf.append(" ").append(key.location()).append('\n');
|
||||
}
|
||||
}
|
||||
LOGGER.debug(buf.toString());
|
||||
|
||||
@@ -105,7 +105,7 @@ public class BiomeManager
|
||||
*/
|
||||
public static void addAdditionalOverworldBiomes(RegistryKey<Biome> biome)
|
||||
{
|
||||
if (!"minecraft".equals(biome.getLocation().getNamespace()) && additionalOverworldBiomes.stream().noneMatch(entry -> entry.getLocation().equals(biome.getLocation())))
|
||||
if (!"minecraft".equals(biome.location().getNamespace()) && additionalOverworldBiomes.stream().noneMatch(entry -> entry.location().equals(biome.location())))
|
||||
{
|
||||
additionalOverworldBiomes.add(biome);
|
||||
}
|
||||
|
||||
@@ -58,7 +58,7 @@ public class DungeonHooks
|
||||
if (type == mob.type)
|
||||
{
|
||||
itr.remove();
|
||||
rarity = mob.itemWeight + rarity;
|
||||
rarity = mob.weight + rarity;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -80,7 +80,7 @@ public class DungeonHooks
|
||||
if (name == mob.type)
|
||||
{
|
||||
dungeonMobs.remove(mob);
|
||||
return mob.itemWeight;
|
||||
return mob.weight;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
|
||||
@@ -60,7 +60,7 @@ public class FarmlandWaterManager
|
||||
@SuppressWarnings("unchecked")
|
||||
public static<T extends SimpleTicket<Vector3d>> T addCustomTicket(World world, T ticket, ChunkPos masterChunk, ChunkPos... additionalChunks)
|
||||
{
|
||||
Preconditions.checkArgument(!world.isRemote, "Water region is only determined server-side");
|
||||
Preconditions.checkArgument(!world.isClientSide, "Water region is only determined server-side");
|
||||
Map<ChunkPos, ChunkTicketManager<Vector3d>> ticketMap = customWaterHandler.computeIfAbsent(world, id -> new MapMaker().weakValues().makeMap());
|
||||
ChunkTicketManager<Vector3d>[] additionalTickets = new ChunkTicketManager[additionalChunks.length];
|
||||
for (int i = 0; i < additionalChunks.length; i++)
|
||||
@@ -157,7 +157,7 @@ public class FarmlandWaterManager
|
||||
}
|
||||
|
||||
private static ChunkTicketManager<Vector3d> getTicketManager(ChunkPos pos, IWorldReader world) {
|
||||
Preconditions.checkArgument(!world.isRemote(), "Water region is only determined server-side");
|
||||
Preconditions.checkArgument(!world.isClientSide(), "Water region is only determined server-side");
|
||||
Map<ChunkPos, ChunkTicketManager<Vector3d>> ticketMap = customWaterHandler.get(world);
|
||||
if (ticketMap == null)
|
||||
{
|
||||
|
||||
@@ -205,17 +205,17 @@ public class ForgeHooks
|
||||
public static boolean canHarvestBlock(@Nonnull BlockState state, @Nonnull PlayerEntity player, @Nonnull IBlockReader world, @Nonnull BlockPos pos)
|
||||
{
|
||||
//state = state.getActualState(world, pos);
|
||||
if (!state.getRequiresTool())
|
||||
if (!state.requiresCorrectToolForDrops())
|
||||
return ForgeEventFactory.doPlayerHarvestCheck(player, state, true);
|
||||
|
||||
ItemStack stack = player.getHeldItemMainhand();
|
||||
ItemStack stack = player.getMainHandItem();
|
||||
ToolType tool = state.getHarvestTool();
|
||||
if (stack.isEmpty() || tool == null)
|
||||
return player.func_234569_d_(state);
|
||||
return player.hasCorrectToolForDrops(state);
|
||||
|
||||
int toolLevel = stack.getHarvestLevel(tool, player, state);
|
||||
if (toolLevel < 0)
|
||||
return player.func_234569_d_(state);
|
||||
return player.hasCorrectToolForDrops(state);
|
||||
|
||||
return ForgeEventFactory.doPlayerHarvestCheck(player, state, toolLevel >= state.getHarvestLevel());
|
||||
}
|
||||
@@ -246,7 +246,7 @@ public class ForgeHooks
|
||||
//Axes check Materials and Blocks now.
|
||||
Set<Material> materials = getPrivateValue(AxeItem.class, null, 0);
|
||||
for (Block block : ForgeRegistries.BLOCKS)
|
||||
if (materials.contains(block.getDefaultState().getMaterial()))
|
||||
if (materials.contains(block.defaultBlockState().getMaterial()))
|
||||
blockToolSetter.accept(block, ToolType.AXE, 0);
|
||||
blocks = getPrivateValue(AxeItem.class, null, 1);
|
||||
blocks.forEach(block -> blockToolSetter.accept(block, ToolType.AXE, 0));
|
||||
@@ -269,19 +269,19 @@ public class ForgeHooks
|
||||
public static boolean onPickBlock(RayTraceResult target, PlayerEntity player, World world)
|
||||
{
|
||||
ItemStack result = ItemStack.EMPTY;
|
||||
boolean isCreative = player.abilities.isCreativeMode;
|
||||
boolean isCreative = player.abilities.instabuild;
|
||||
TileEntity te = null;
|
||||
|
||||
if (target.getType() == RayTraceResult.Type.BLOCK)
|
||||
{
|
||||
BlockPos pos = ((BlockRayTraceResult)target).getPos();
|
||||
BlockPos pos = ((BlockRayTraceResult)target).getBlockPos();
|
||||
BlockState state = world.getBlockState(pos);
|
||||
|
||||
if (state.isAir(world, pos))
|
||||
return false;
|
||||
|
||||
if (isCreative && Screen.hasControlDown() && state.hasTileEntity())
|
||||
te = world.getTileEntity(pos);
|
||||
te = world.getBlockEntity(pos);
|
||||
|
||||
result = state.getPickBlock(target, world, pos, player);
|
||||
|
||||
@@ -301,21 +301,21 @@ public class ForgeHooks
|
||||
return false;
|
||||
|
||||
if (te != null)
|
||||
Minecraft.getInstance().storeTEInStack(result, te);
|
||||
Minecraft.getInstance().addCustomNbtData(result, te);
|
||||
|
||||
if (isCreative)
|
||||
{
|
||||
player.inventory.setPickedItemStack(result);
|
||||
Minecraft.getInstance().playerController.sendSlotPacket(player.getHeldItem(Hand.MAIN_HAND), 36 + player.inventory.currentItem);
|
||||
player.inventory.setPickedItem(result);
|
||||
Minecraft.getInstance().gameMode.handleCreativeModeItemAdd(player.getItemInHand(Hand.MAIN_HAND), 36 + player.inventory.selected);
|
||||
return true;
|
||||
}
|
||||
int slot = player.inventory.getSlotFor(result);
|
||||
int slot = player.inventory.findSlotMatchingItem(result);
|
||||
if (slot != -1)
|
||||
{
|
||||
if (PlayerInventory.isHotbar(slot))
|
||||
player.inventory.currentItem = slot;
|
||||
if (PlayerInventory.isHotbarSlot(slot))
|
||||
player.inventory.selected = slot;
|
||||
else
|
||||
Minecraft.getInstance().playerController.pickItem(slot);
|
||||
Minecraft.getInstance().gameMode.handlePickItem(slot);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@@ -389,7 +389,7 @@ public class ForgeHooks
|
||||
{
|
||||
int looting = 0;
|
||||
if (killer instanceof LivingEntity)
|
||||
looting = EnchantmentHelper.getLootingModifier((LivingEntity)killer);
|
||||
looting = EnchantmentHelper.getMobLooting((LivingEntity)killer);
|
||||
if (target instanceof LivingEntity)
|
||||
looting = getLootingLevel((LivingEntity)target, cause, looting);
|
||||
return looting;
|
||||
@@ -463,7 +463,7 @@ public class ForgeHooks
|
||||
public static ItemEntity onPlayerTossEvent(@Nonnull PlayerEntity player, @Nonnull ItemStack item, boolean includeName)
|
||||
{
|
||||
player.captureDrops(Lists.newArrayList());
|
||||
ItemEntity ret = player.dropItem(item, false, includeName);
|
||||
ItemEntity ret = player.drop(item, false, includeName);
|
||||
player.captureDrops(null);
|
||||
|
||||
if (ret == null)
|
||||
@@ -473,8 +473,8 @@ public class ForgeHooks
|
||||
if (MinecraftForge.EVENT_BUS.post(event))
|
||||
return null;
|
||||
|
||||
if (!player.world.isRemote)
|
||||
player.getEntityWorld().addEntity(event.getEntityItem());
|
||||
if (!player.level.isClientSide)
|
||||
player.getCommandSenderWorld().addFreshEntity(event.getEntityItem());
|
||||
return event.getEntityItem();
|
||||
}
|
||||
|
||||
@@ -519,7 +519,7 @@ public class ForgeHooks
|
||||
if (ichat == null)
|
||||
ichat = new StringTextComponent(part);
|
||||
else
|
||||
ichat.appendString(part);
|
||||
ichat.append(part);
|
||||
}
|
||||
lastEnd = end;
|
||||
String url = string.substring(start, end);
|
||||
@@ -535,7 +535,7 @@ public class ForgeHooks
|
||||
if (ichat == null)
|
||||
ichat = new StringTextComponent(url);
|
||||
else
|
||||
ichat.appendString(url);
|
||||
ichat.append(url);
|
||||
continue;
|
||||
}
|
||||
url = "http://" + url;
|
||||
@@ -545,13 +545,13 @@ public class ForgeHooks
|
||||
{
|
||||
// Bad syntax bail out!
|
||||
if (ichat == null) ichat = new StringTextComponent(url);
|
||||
else ichat.appendString(url);
|
||||
else ichat.append(url);
|
||||
continue;
|
||||
}
|
||||
|
||||
// Set the click event and append the link.
|
||||
ClickEvent click = new ClickEvent(ClickEvent.Action.OPEN_URL, url);
|
||||
link.setStyle(link.getStyle().setClickEvent(click).setUnderlined(true).setColor(Color.fromTextFormatting(TextFormatting.BLUE)));
|
||||
link.setStyle(link.getStyle().withClickEvent(click).setUnderlined(true).withColor(Color.fromLegacyFormat(TextFormatting.BLUE)));
|
||||
if (ichat == null)
|
||||
ichat = new StringTextComponent("");
|
||||
ichat.append(link);
|
||||
@@ -570,28 +570,28 @@ public class ForgeHooks
|
||||
{
|
||||
// Logic from tryHarvestBlock for pre-canceling the event
|
||||
boolean preCancelEvent = false;
|
||||
ItemStack itemstack = entityPlayer.getHeldItemMainhand();
|
||||
if (!itemstack.isEmpty() && !itemstack.getItem().canPlayerBreakBlockWhileHolding(world.getBlockState(pos), world, pos, entityPlayer))
|
||||
ItemStack itemstack = entityPlayer.getMainHandItem();
|
||||
if (!itemstack.isEmpty() && !itemstack.getItem().canAttackBlock(world.getBlockState(pos), world, pos, entityPlayer))
|
||||
{
|
||||
preCancelEvent = true;
|
||||
}
|
||||
|
||||
if (gameType.hasLimitedInteractions())
|
||||
if (gameType.isBlockPlacingRestricted())
|
||||
{
|
||||
if (gameType == GameType.SPECTATOR)
|
||||
preCancelEvent = true;
|
||||
|
||||
if (!entityPlayer.isAllowEdit())
|
||||
if (!entityPlayer.mayBuild())
|
||||
{
|
||||
if (itemstack.isEmpty() || !itemstack.canDestroy(world.getTags(), new CachedBlockInfo(world, pos, false)))
|
||||
if (itemstack.isEmpty() || !itemstack.hasAdventureModeBreakTagForBlock(world.getTagManager(), new CachedBlockInfo(world, pos, false)))
|
||||
preCancelEvent = true;
|
||||
}
|
||||
}
|
||||
|
||||
// Tell client the block is gone immediately then process events
|
||||
if (world.getTileEntity(pos) == null)
|
||||
if (world.getBlockEntity(pos) == null)
|
||||
{
|
||||
entityPlayer.connection.sendPacket(new SChangeBlockPacket(DUMMY_WORLD, pos));
|
||||
entityPlayer.connection.send(new SChangeBlockPacket(DUMMY_WORLD, pos));
|
||||
}
|
||||
|
||||
// Post the block break event
|
||||
@@ -604,16 +604,16 @@ public class ForgeHooks
|
||||
if (event.isCanceled())
|
||||
{
|
||||
// Let the client know the block still exists
|
||||
entityPlayer.connection.sendPacket(new SChangeBlockPacket(world, pos));
|
||||
entityPlayer.connection.send(new SChangeBlockPacket(world, pos));
|
||||
|
||||
// Update any tile entity data for this block
|
||||
TileEntity tileentity = world.getTileEntity(pos);
|
||||
TileEntity tileentity = world.getBlockEntity(pos);
|
||||
if (tileentity != null)
|
||||
{
|
||||
IPacket<?> pkt = tileentity.getUpdatePacket();
|
||||
if (pkt != null)
|
||||
{
|
||||
entityPlayer.connection.sendPacket(pkt);
|
||||
entityPlayer.connection.send(pkt);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -622,11 +622,11 @@ public class ForgeHooks
|
||||
|
||||
public static ActionResultType onPlaceItemIntoWorld(@Nonnull ItemUseContext context)
|
||||
{
|
||||
ItemStack itemstack = context.getItem();
|
||||
World world = context.getWorld();
|
||||
ItemStack itemstack = context.getItemInHand();
|
||||
World world = context.getLevel();
|
||||
|
||||
PlayerEntity player = context.getPlayer();
|
||||
if (player != null && !player.abilities.allowEdit && !itemstack.canPlaceOn(world.getTags(), new CachedBlockInfo(world, context.getPos(), false)))
|
||||
if (player != null && !player.abilities.mayBuild && !itemstack.hasAdventureModePlaceTagForBlock(world.getTagManager(), new CachedBlockInfo(world, context.getClickedPos(), false)))
|
||||
return ActionResultType.PASS;
|
||||
|
||||
// handle all placement events here
|
||||
@@ -640,13 +640,13 @@ public class ForgeHooks
|
||||
world.captureBlockSnapshots = true;
|
||||
|
||||
ItemStack copy = itemstack.copy();
|
||||
ActionResultType ret = itemstack.getItem().onItemUse(context);
|
||||
ActionResultType ret = itemstack.getItem().useOn(context);
|
||||
if (itemstack.isEmpty())
|
||||
ForgeEventFactory.onPlayerDestroyItem(player, copy, context.getHand());
|
||||
|
||||
world.captureBlockSnapshots = false;
|
||||
|
||||
if (ret.isSuccessOrConsume())
|
||||
if (ret.consumesAction())
|
||||
{
|
||||
// save new item data
|
||||
int newSize = itemstack.getCount();
|
||||
@@ -663,7 +663,7 @@ public class ForgeHooks
|
||||
itemstack.setCount(size);
|
||||
itemstack.setTag(nbt);
|
||||
|
||||
Direction side = context.getFace();
|
||||
Direction side = context.getClickedFace();
|
||||
|
||||
boolean eventResult = false;
|
||||
if (blockSnapshots.size() > 1)
|
||||
@@ -697,12 +697,12 @@ public class ForgeHooks
|
||||
int updateFlag = snap.getFlag();
|
||||
BlockState oldBlock = snap.getReplacedBlock();
|
||||
BlockState newBlock = world.getBlockState(snap.getPos());
|
||||
newBlock.onBlockAdded(world, snap.getPos(), oldBlock, false);
|
||||
newBlock.onPlace(world, snap.getPos(), oldBlock, false);
|
||||
|
||||
world.markAndNotifyBlock(snap.getPos(), world.getChunkAt(snap.getPos()), oldBlock, newBlock, updateFlag, 512);
|
||||
}
|
||||
if (player != null)
|
||||
player.addStat(Stats.ITEM_USED.get(item));
|
||||
player.awardStat(Stats.ITEM_USED.get(item));
|
||||
}
|
||||
}
|
||||
world.capturedBlockSnapshots.clear();
|
||||
@@ -722,9 +722,9 @@ public class ForgeHooks
|
||||
if (MinecraftForge.EVENT_BUS.post(e)) return false;
|
||||
if (e.getOutput().isEmpty()) return true;
|
||||
|
||||
outputSlot.setInventorySlotContents(0, e.getOutput());
|
||||
outputSlot.setItem(0, e.getOutput());
|
||||
container.setMaximumCost(e.getCost());
|
||||
container.materialCost = e.getMaterialCost();
|
||||
container.repairItemCountCost = e.getMaterialCost();
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -750,7 +750,7 @@ public class ForgeHooks
|
||||
if (stack.getItem().hasContainerItem(stack))
|
||||
{
|
||||
stack = stack.getItem().getContainerItem(stack);
|
||||
if (!stack.isEmpty() && stack.isDamageable() && stack.getDamage() > stack.getMaxDamage())
|
||||
if (!stack.isEmpty() && stack.isDamageableItem() && stack.getDamageValue() > stack.getMaxDamage())
|
||||
{
|
||||
ForgeEventFactory.onPlayerDestroyItem(craftingPlayer.get(), stack, null);
|
||||
return ItemStack.EMPTY;
|
||||
@@ -763,7 +763,7 @@ public class ForgeHooks
|
||||
public static boolean onPlayerAttackTarget(PlayerEntity player, Entity target)
|
||||
{
|
||||
if (MinecraftForge.EVENT_BUS.post(new AttackEntityEvent(player, target))) return false;
|
||||
ItemStack stack = player.getHeldItemMainhand();
|
||||
ItemStack stack = player.getMainHandItem();
|
||||
return stack.isEmpty() || !stack.getItem().onLeftClickEntity(stack, player, target);
|
||||
}
|
||||
|
||||
@@ -784,7 +784,7 @@ public class ForgeHooks
|
||||
|
||||
public static ActionResultType onInteractEntityAt(PlayerEntity player, Entity entity, RayTraceResult ray, Hand hand)
|
||||
{
|
||||
Vector3d vec3d = ray.getHitVec().subtract(entity.getPositionVec());
|
||||
Vector3d vec3d = ray.getLocation().subtract(entity.position());
|
||||
return onInteractEntityAt(player, entity, vec3d, hand);
|
||||
}
|
||||
|
||||
@@ -909,7 +909,7 @@ public class ForgeHooks
|
||||
.overlay(new ResourceLocation("block/water_overlay"))
|
||||
.translationKey("block.minecraft.water")
|
||||
.color(0xFF3F76E4)
|
||||
.sound(SoundEvents.ITEM_BUCKET_FILL, SoundEvents.ITEM_BUCKET_EMPTY)
|
||||
.sound(SoundEvents.BUCKET_FILL, SoundEvents.BUCKET_EMPTY)
|
||||
.build(fluid);
|
||||
if (fluid instanceof LavaFluid)
|
||||
return net.minecraftforge.fluids.FluidAttributes.builder(
|
||||
@@ -917,7 +917,7 @@ public class ForgeHooks
|
||||
new ResourceLocation("block/lava_flow"))
|
||||
.translationKey("block.minecraft.lava")
|
||||
.luminosity(15).density(3000).viscosity(6000).temperature(1300)
|
||||
.sound(SoundEvents.ITEM_BUCKET_FILL_LAVA, SoundEvents.ITEM_BUCKET_EMPTY_LAVA)
|
||||
.sound(SoundEvents.BUCKET_FILL_LAVA, SoundEvents.BUCKET_EMPTY_LAVA)
|
||||
.build(fluid);
|
||||
throw new RuntimeException("Mod fluids must override createAttributes.");
|
||||
}
|
||||
@@ -942,7 +942,7 @@ public class ForgeHooks
|
||||
MobSpawnInfoBuilder spawnBuilder = new MobSpawnInfoBuilder(spawns);
|
||||
BiomeLoadingEvent event = new BiomeLoadingEvent(name, climate, category, depth, scale, effects, genBuilder, spawnBuilder);
|
||||
MinecraftForge.EVENT_BUS.post(event);
|
||||
return callback.apply(event.getClimate(), event.getCategory(), event.getDepth(), event.getScale(), event.getEffects(), event.getGeneration().build(), event.getSpawns().copy()).setRegistryName(name);
|
||||
return callback.apply(event.getClimate(), event.getCategory(), event.getDepth(), event.getScale(), event.getEffects(), event.getGeneration().build(), event.getSpawns().build()).setRegistryName(name);
|
||||
}
|
||||
|
||||
private static class LootTableContext
|
||||
@@ -995,7 +995,7 @@ public class ForgeHooks
|
||||
ctx.resetPoolCtx();
|
||||
|
||||
if (json.has("name"))
|
||||
return JSONUtils.getString(json, "name");
|
||||
return JSONUtils.getAsString(json, "name");
|
||||
|
||||
if (ctx.custom)
|
||||
return "custom#" + json.hashCode(); //We don't care about custom ones modders shouldn't be editing them!
|
||||
@@ -1014,16 +1014,16 @@ public class ForgeHooks
|
||||
ctx.entryCount++;
|
||||
|
||||
if (json.has("entryName"))
|
||||
return ctx.validateEntryName(JSONUtils.getString(json, "entryName"));
|
||||
return ctx.validateEntryName(JSONUtils.getAsString(json, "entryName"));
|
||||
|
||||
if (ctx.custom)
|
||||
return "custom#" + json.hashCode(); //We don't care about custom ones modders shouldn't be editing them!
|
||||
|
||||
String name = null;
|
||||
if ("item".equals(type))
|
||||
name = JSONUtils.getString(json, "name");
|
||||
name = JSONUtils.getAsString(json, "name");
|
||||
else if ("loot_table".equals(type))
|
||||
name = JSONUtils.getString(json, "name");
|
||||
name = JSONUtils.getAsString(json, "name");
|
||||
else if ("empty".equals(type))
|
||||
name = "empty";
|
||||
|
||||
@@ -1086,7 +1086,7 @@ public class ForgeHooks
|
||||
if (enchantmentsNbt.size() == 1)
|
||||
{
|
||||
CompoundNBT nbttagcompound = enchantmentsNbt.getCompound(0);
|
||||
ResourceLocation resourceLocation = ResourceLocation.tryCreate(nbttagcompound.getString("id"));
|
||||
ResourceLocation resourceLocation = ResourceLocation.tryParse(nbttagcompound.getString("id"));
|
||||
if (resourceLocation != null && ForgeRegistries.ENCHANTMENTS.containsKey(resourceLocation))
|
||||
{
|
||||
return resourceLocation.getNamespace();
|
||||
@@ -1095,7 +1095,7 @@ public class ForgeHooks
|
||||
}
|
||||
else if (item instanceof PotionItem || item instanceof TippedArrowItem)
|
||||
{
|
||||
Potion potionType = PotionUtils.getPotionFromItem(itemStack);
|
||||
Potion potionType = PotionUtils.getPotion(itemStack);
|
||||
ResourceLocation resourceLocation = ForgeRegistries.POTION_TYPES.getKey(potionType);
|
||||
if (resourceLocation != null)
|
||||
{
|
||||
@@ -1151,18 +1151,18 @@ public class ForgeHooks
|
||||
private static class DummyBlockReader implements IBlockReader {
|
||||
|
||||
@Override
|
||||
public TileEntity getTileEntity(BlockPos pos) {
|
||||
public TileEntity getBlockEntity(BlockPos pos) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockState getBlockState(BlockPos pos) {
|
||||
return Blocks.AIR.getDefaultState();
|
||||
return Blocks.AIR.defaultBlockState();
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidState getFluidState(BlockPos pos) {
|
||||
return Fluids.EMPTY.getDefaultState();
|
||||
return Fluids.EMPTY.defaultFluidState();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1184,9 +1184,9 @@ public class ForgeHooks
|
||||
//TODO 1.17 remove parsing the forge added "optional" array. Still here for compatibility with previously created tags.
|
||||
if (json.has("optional"))
|
||||
{
|
||||
for (JsonElement entry : JSONUtils.getJsonArray(json, "optional"))
|
||||
for (JsonElement entry : JSONUtils.getAsJsonArray(json, "optional"))
|
||||
{
|
||||
String s = JSONUtils.getString(entry, "value");
|
||||
String s = JSONUtils.convertToString(entry, "value");
|
||||
if (!s.startsWith("#"))
|
||||
list.add(new ITag.OptionalItemEntry(new ResourceLocation(s)));
|
||||
else
|
||||
@@ -1196,9 +1196,9 @@ public class ForgeHooks
|
||||
|
||||
if (json.has("remove"))
|
||||
{
|
||||
for (JsonElement entry : JSONUtils.getJsonArray(json, "remove"))
|
||||
for (JsonElement entry : JSONUtils.getAsJsonArray(json, "remove"))
|
||||
{
|
||||
String s = JSONUtils.getString(entry, "value");
|
||||
String s = JSONUtils.convertToString(entry, "value");
|
||||
ITag.ITagEntry dummy;
|
||||
if (!s.startsWith("#"))
|
||||
dummy = new ITag.ItemEntry(new ResourceLocation(s));
|
||||
@@ -1216,7 +1216,7 @@ public class ForgeHooks
|
||||
@Nullable
|
||||
public static IDataSerializer<?> getSerializer(int id, IntIdentityHashBiMap<IDataSerializer<?>> vanilla)
|
||||
{
|
||||
IDataSerializer<?> serializer = vanilla.getByValue(id);
|
||||
IDataSerializer<?> serializer = vanilla.byId(id);
|
||||
if (serializer == null)
|
||||
{
|
||||
DataSerializerEntry entry = ((ForgeRegistry<DataSerializerEntry>)ForgeRegistries.DATA_SERIALIZERS).getValue(id);
|
||||
@@ -1265,7 +1265,7 @@ public class ForgeHooks
|
||||
public static synchronized void updateBurns()
|
||||
{
|
||||
VANILLA_BURNS.clear();
|
||||
FurnaceTileEntity.getBurnTimes().entrySet().forEach(e -> VANILLA_BURNS.put(e.getKey().delegate, e.getValue()));
|
||||
FurnaceTileEntity.getFuel().entrySet().forEach(e -> VANILLA_BURNS.put(e.getKey().delegate, e.getValue()));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1333,16 +1333,16 @@ public class ForgeHooks
|
||||
{
|
||||
if (structureReferences.remove(null) != null)
|
||||
{
|
||||
chunk.setModified(true);
|
||||
chunk.setUnsaved(true);
|
||||
}
|
||||
chunk.setStructureReferences(structureReferences);
|
||||
chunk.setAllReferences(structureReferences);
|
||||
}
|
||||
|
||||
private static final Set<String> VANILLA_DIMS = Sets.newHashSet("minecraft:overworld", "minecraft:the_nether", "minecraft:the_end");
|
||||
private static final String DIMENSIONS_KEY = "dimensions";
|
||||
private static final String SEED_KEY = "seed";
|
||||
//No to static init!
|
||||
private static final LazyValue<Codec<SimpleRegistry<Dimension>>> CODEC = new LazyValue<>(() -> SimpleRegistry.getSimpleRegistryCodec(Registry.DIMENSION_KEY, Lifecycle.stable(), Dimension.CODEC).xmap(Dimension::func_236062_a_, Function.identity()));
|
||||
private static final LazyValue<Codec<SimpleRegistry<Dimension>>> CODEC = new LazyValue<>(() -> SimpleRegistry.dataPackCodec(Registry.LEVEL_STEM_REGISTRY, Lifecycle.stable(), Dimension.CODEC).xmap(Dimension::sortMap, Function.identity()));
|
||||
|
||||
/**
|
||||
* Restores previously "deleted" dimensions to the world.
|
||||
@@ -1364,31 +1364,31 @@ public class ForgeHooks
|
||||
if (!currentDimNames.containsAll(VANILLA_DIMS))
|
||||
{
|
||||
LOGGER.warn("Detected missing vanilla dimensions from the world!");
|
||||
DynamicRegistries regs = ObfuscationReflectionHelper.getPrivateValue(WorldSettingsImport.class, ops, "field_240872_d_");
|
||||
DynamicRegistries regs = ObfuscationReflectionHelper.getPrivateValue(WorldSettingsImport.class, ops, "registryHolder");
|
||||
if (regs == null) // should not happen, but it could after a MC version update.
|
||||
throw new RuntimeException("Could not access dynamic registries using reflection. " +
|
||||
"The world was detected to have missing vanilla dimensions and the attempted fix did not work.");
|
||||
|
||||
long seed = data.get(SEED_KEY).get().result().map(d -> d.asLong(0L)).orElse(0L);
|
||||
Registry<Biome> biomeReg = regs.getRegistry(Registry.BIOME_KEY);
|
||||
Registry<DimensionType> typeReg = regs.getRegistry(Registry.DIMENSION_TYPE_KEY);
|
||||
Registry<DimensionSettings> noiseReg = regs.getRegistry(Registry.NOISE_SETTINGS_KEY);
|
||||
Registry<Biome> biomeReg = regs.registryOrThrow(Registry.BIOME_REGISTRY);
|
||||
Registry<DimensionType> typeReg = regs.registryOrThrow(Registry.DIMENSION_TYPE_REGISTRY);
|
||||
Registry<DimensionSettings> noiseReg = regs.registryOrThrow(Registry.NOISE_GENERATOR_SETTINGS_REGISTRY);
|
||||
|
||||
//Loads the default nether and end
|
||||
SimpleRegistry<Dimension> dimReg = DimensionType.getDefaultSimpleRegistry(typeReg, biomeReg, noiseReg, seed);
|
||||
SimpleRegistry<Dimension> dimReg = DimensionType.defaultDimensions(typeReg, biomeReg, noiseReg, seed);
|
||||
//Loads the default overworld
|
||||
dimReg = DimensionGeneratorSettings.func_242749_a(typeReg, dimReg, DimensionGeneratorSettings.func_242750_a(biomeReg, noiseReg, seed));
|
||||
dimReg = DimensionGeneratorSettings.withOverworld(typeReg, dimReg, DimensionGeneratorSettings.makeDefaultOverworld(biomeReg, noiseReg, seed));
|
||||
|
||||
// Encode and decode the registry. This adds any dimensions from datapacks (see SimpleRegistryCodec#decode), but only the vanilla overrides are needed.
|
||||
// This assumes that the datapacks for the vanilla dimensions have not changed since they were "deleted"
|
||||
// If they did, this will be seen in newly generated chunks.
|
||||
// Since this is to fix an older world, from before the fixes by forge, there is no way to know the state of the dimension when it was "deleted".
|
||||
dimReg = CODEC.getValue().encodeStart(WorldGenSettingsExport.create(ops, regs), dimReg).flatMap(t -> CODEC.getValue().parse(ops, t)).result().orElse(dimReg);
|
||||
dimReg = CODEC.get().encodeStart(WorldGenSettingsExport.create(ops, regs), dimReg).flatMap(t -> CODEC.get().parse(ops, t)).result().orElse(dimReg);
|
||||
for (String name : VANILLA_DIMS)
|
||||
{
|
||||
if (currentDimNames.contains(name))
|
||||
continue;
|
||||
Dimension dim = dimReg.getOrDefault(new ResourceLocation(name));
|
||||
Dimension dim = dimReg.get(new ResourceLocation(name));
|
||||
if (dim == null)
|
||||
{
|
||||
LOGGER.error("The world is missing dimension: " + name + ", but the attempt to re-inject it failed.");
|
||||
@@ -1438,10 +1438,10 @@ public class ForgeHooks
|
||||
|
||||
finalMap.forEach((k, v) ->
|
||||
{
|
||||
AttributeModifierMap modifiers = GlobalEntityTypeAttributes.getAttributesForEntity(k);
|
||||
AttributeModifierMap modifiers = GlobalEntityTypeAttributes.getSupplier(k);
|
||||
AttributeModifierMap.MutableAttribute newMutable = modifiers != null ? new AttributeModifierMap.MutableAttribute(modifiers) : new AttributeModifierMap.MutableAttribute();
|
||||
newMutable.combine(v);
|
||||
FORGE_ATTRIBUTES.put(k, newMutable.create());
|
||||
FORGE_ATTRIBUTES.put(k, newMutable.build());
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -60,7 +60,7 @@ public class ForgeInternalHandler
|
||||
{
|
||||
entity.remove();
|
||||
event.setCanceled(true);
|
||||
event.getWorld().addEntity(newEntity);
|
||||
event.getWorld().addFreshEntity(newEntity);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -90,7 +90,7 @@ public class ForgeInternalHandler
|
||||
@SubscribeEvent
|
||||
public void onChunkUnload(ChunkEvent.Unload event)
|
||||
{
|
||||
if (!event.getWorld().isRemote())
|
||||
if (!event.getWorld().isClientSide())
|
||||
FarmlandWaterManager.removeTickets(event.getChunk());
|
||||
}
|
||||
|
||||
@@ -106,7 +106,7 @@ public class ForgeInternalHandler
|
||||
@SubscribeEvent
|
||||
public void playerLogin(PlayerEvent.PlayerLoggedInEvent event)
|
||||
{
|
||||
UsernameCache.setUsername(event.getPlayer().getUniqueID(), event.getPlayer().getGameProfile().getName());
|
||||
UsernameCache.setUsername(event.getPlayer().getUUID(), event.getPlayer().getGameProfile().getName());
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
|
||||
@@ -103,11 +103,11 @@ public class ForgeMod implements WorldPersistenceHooks.WorldPersistenceHook
|
||||
|
||||
private static final DeferredRegister<Attribute> ATTRIBUTES = DeferredRegister.create(Attribute.class, "forge");
|
||||
|
||||
public static final RegistryObject<Attribute> SWIM_SPEED = ATTRIBUTES.register("swim_speed", () -> new RangedAttribute("forge.swimSpeed", 1.0D, 0.0D, 1024.0D).setShouldWatch(true));
|
||||
public static final RegistryObject<Attribute> NAMETAG_DISTANCE = ATTRIBUTES.register("nametag_distance", () -> new RangedAttribute("forge.nameTagDistance", 64.0D, 0.0D, 64.0).setShouldWatch(true));
|
||||
public static final RegistryObject<Attribute> ENTITY_GRAVITY = ATTRIBUTES.register("entity_gravity", () -> new RangedAttribute("forge.entity_gravity", 0.08D, -8.0D, 8.0D).setShouldWatch(true));
|
||||
public static final RegistryObject<Attribute> SWIM_SPEED = ATTRIBUTES.register("swim_speed", () -> new RangedAttribute("forge.swimSpeed", 1.0D, 0.0D, 1024.0D).setSyncable(true));
|
||||
public static final RegistryObject<Attribute> NAMETAG_DISTANCE = ATTRIBUTES.register("nametag_distance", () -> new RangedAttribute("forge.nameTagDistance", 64.0D, 0.0D, 64.0).setSyncable(true));
|
||||
public static final RegistryObject<Attribute> ENTITY_GRAVITY = ATTRIBUTES.register("entity_gravity", () -> new RangedAttribute("forge.entity_gravity", 0.08D, -8.0D, 8.0D).setSyncable(true));
|
||||
|
||||
public static final RegistryObject<Attribute> REACH_DISTANCE = ATTRIBUTES.register("reach_distance", () -> new RangedAttribute("generic.reachDistance", 5.0D, 0.0D, 1024.0D).setShouldWatch(true));
|
||||
public static final RegistryObject<Attribute> REACH_DISTANCE = ATTRIBUTES.register("reach_distance", () -> new RangedAttribute("generic.reachDistance", 5.0D, 0.0D, 1024.0D).setSyncable(true));
|
||||
|
||||
private static boolean enableMilkFluid = false;
|
||||
public static final RegistryObject<Fluid> MILK = RegistryObject.of(new ResourceLocation("milk"), ForgeRegistries.FLUIDS);
|
||||
|
||||
@@ -93,7 +93,7 @@ public class ForgeTagHandler
|
||||
{
|
||||
TagRegistry<T> tagRegistry = getTagRegistry(registry);
|
||||
if (tagRegistry == null) throw new IllegalArgumentException("Registry " + registry.getRegistryName() + " does not support tag types.");
|
||||
return tagRegistry.createTag(name.toString());
|
||||
return tagRegistry.bind(name.toString());
|
||||
}
|
||||
return TagRegistry.createDelayedTag(registry.getRegistryName(), name);
|
||||
}
|
||||
@@ -264,13 +264,13 @@ public class ForgeTagHandler
|
||||
if (makeEmpty)
|
||||
{
|
||||
if (withOptional)
|
||||
builder.put(registryName, tagRegistry.reinjectOptionalTags(ITagCollection.getTagCollectionFromMap(Collections.emptyMap())));
|
||||
builder.put(registryName, tagRegistry.reinjectOptionalTags(ITagCollection.of(Collections.emptyMap())));
|
||||
else
|
||||
builder.put(registryName, ITagCollection.getTagCollectionFromMap(Collections.emptyMap()));
|
||||
builder.put(registryName, ITagCollection.of(Collections.emptyMap()));
|
||||
}
|
||||
else
|
||||
{
|
||||
builder.put(registryName, ITagCollection.getTagCollectionFromMap(tagRegistry.getTags().stream().distinct().collect(Collectors.toMap(INamedTag::getName, namedTag -> namedTag))));
|
||||
builder.put(registryName, ITagCollection.of(tagRegistry.getWrappers().stream().distinct().collect(Collectors.toMap(INamedTag::getName, namedTag -> namedTag))));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -290,7 +290,7 @@ public class ForgeTagHandler
|
||||
{
|
||||
LOGGER.debug("Populated the TagCollectionManager with {} extra types", customTagTypes.size());
|
||||
}
|
||||
return ITagCollectionSupplier.getTagCollectionSupplier(blockTags, itemTags, fluidTags, entityTypeTags);
|
||||
return ITagCollectionSupplier.of(blockTags, itemTags, fluidTags, entityTypeTags);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -303,7 +303,7 @@ public class ForgeTagHandler
|
||||
ImmutableMap.Builder<ResourceLocation, ITagCollection<?>> builder = ImmutableMap.builder();
|
||||
for (TagCollectionReaderInfo info : tagCollectionReaders)
|
||||
{
|
||||
builder.put(info.tagType, info.reader.buildTagCollectionFromMap(info.tagBuilders));
|
||||
builder.put(info.tagType, info.reader.load(info.tagBuilders));
|
||||
}
|
||||
customTagTypes = builder.build();
|
||||
}
|
||||
@@ -329,7 +329,7 @@ public class ForgeTagHandler
|
||||
CompletableFuture<List<TagCollectionReaderInfo>> customResults = CompletableFuture.completedFuture(new ArrayList<>());
|
||||
for (Map.Entry<ResourceLocation, TagCollectionReader<?>> entry : readers.entrySet())
|
||||
{
|
||||
customResults = customResults.thenCombine(entry.getValue().readTagsFromManager(resourceManager, backgroundExecutor), (results, result) -> {
|
||||
customResults = customResults.thenCombine(entry.getValue().prepare(resourceManager, backgroundExecutor), (results, result) -> {
|
||||
results.add(new TagCollectionReaderInfo(entry.getKey(), entry.getValue(), result));
|
||||
return results;
|
||||
});
|
||||
@@ -368,7 +368,7 @@ public class ForgeTagHandler
|
||||
TagRegistry<?> tagRegistry = TagRegistryManager.get(registryName);
|
||||
if (tagRegistry != null)
|
||||
{
|
||||
builder.put(registryName, ITagCollection.getTagCollectionFromMap(Collections.emptyMap()));
|
||||
builder.put(registryName, ITagCollection.of(Collections.emptyMap()));
|
||||
}
|
||||
}
|
||||
return withSpecificCustom(tagCollectionSupplier, builder.build());
|
||||
@@ -384,27 +384,27 @@ public class ForgeTagHandler
|
||||
return new ITagCollectionSupplier()
|
||||
{
|
||||
@Override
|
||||
public ITagCollection<Block> getBlockTags()
|
||||
public ITagCollection<Block> getBlocks()
|
||||
{
|
||||
return tagCollectionSupplier.getBlockTags();
|
||||
return tagCollectionSupplier.getBlocks();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ITagCollection<Item> getItemTags()
|
||||
public ITagCollection<Item> getItems()
|
||||
{
|
||||
return tagCollectionSupplier.getItemTags();
|
||||
return tagCollectionSupplier.getItems();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ITagCollection<Fluid> getFluidTags()
|
||||
public ITagCollection<Fluid> getFluids()
|
||||
{
|
||||
return tagCollectionSupplier.getFluidTags();
|
||||
return tagCollectionSupplier.getFluids();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ITagCollection<EntityType<?>> getEntityTypeTags()
|
||||
public ITagCollection<EntityType<?>> getEntityTypes()
|
||||
{
|
||||
return tagCollectionSupplier.getEntityTypeTags();
|
||||
return tagCollectionSupplier.getEntityTypes();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -58,6 +58,6 @@ public interface IExtensibleEnum
|
||||
* Use this instead of {@link IStringSerializable#createEnumCodec(Supplier, Function)} for extensible enums because this not cache the enum values on construction
|
||||
*/
|
||||
static <E extends Enum<E> & IStringSerializable> Codec<E> createCodecForExtensibleEnum(Supplier<E[]> valuesSupplier, Function<? super String, ? extends E> enumValueFromNameFunction) {
|
||||
return IStringSerializable.createCodec(Enum::ordinal, (id) -> valuesSupplier.get()[id], enumValueFromNameFunction);
|
||||
return IStringSerializable.fromStringResolver(Enum::ordinal, (id) -> valuesSupplier.get()[id], enumValueFromNameFunction);
|
||||
}
|
||||
}
|
||||
@@ -43,13 +43,13 @@ public class VillagerTradingManager
|
||||
|
||||
static
|
||||
{
|
||||
VillagerTrades.VILLAGER_DEFAULT_TRADES.entrySet().forEach(e ->
|
||||
VillagerTrades.TRADES.entrySet().forEach(e ->
|
||||
{
|
||||
Int2ObjectMap<ITrade[]> copy = new Int2ObjectOpenHashMap<>();
|
||||
e.getValue().int2ObjectEntrySet().forEach(ent -> copy.put(ent.getIntKey(), Arrays.copyOf(ent.getValue(), ent.getValue().length)));
|
||||
VANILLA_TRADES.put(e.getKey(), copy);
|
||||
});
|
||||
VillagerTrades.field_221240_b.int2ObjectEntrySet().forEach(e -> WANDERER_TRADES.put(e.getIntKey(), Arrays.copyOf(e.getValue(), e.getValue().length)));
|
||||
VillagerTrades.WANDERING_TRADER_TRADES.int2ObjectEntrySet().forEach(e -> WANDERER_TRADES.put(e.getIntKey(), Arrays.copyOf(e.getValue(), e.getValue().length)));
|
||||
}
|
||||
|
||||
static void loadTrades(FMLServerAboutToStartEvent e)
|
||||
@@ -68,8 +68,8 @@ public class VillagerTradingManager
|
||||
Arrays.stream(WANDERER_TRADES.get(1)).forEach(generic::add);
|
||||
Arrays.stream(WANDERER_TRADES.get(2)).forEach(rare::add);
|
||||
MinecraftForge.EVENT_BUS.post(new WandererTradesEvent(generic, rare));
|
||||
VillagerTrades.field_221240_b.put(1, generic.toArray(new ITrade[0]));
|
||||
VillagerTrades.field_221240_b.put(2, rare.toArray(new ITrade[0]));
|
||||
VillagerTrades.WANDERING_TRADER_TRADES.put(1, generic.toArray(new ITrade[0]));
|
||||
VillagerTrades.WANDERING_TRADER_TRADES.put(2, rare.toArray(new ITrade[0]));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -92,7 +92,7 @@ public class VillagerTradingManager
|
||||
MinecraftForge.EVENT_BUS.post(new VillagerTradesEvent(mutableTrades, prof));
|
||||
Int2ObjectMap<ITrade[]> newTrades = new Int2ObjectOpenHashMap<>();
|
||||
mutableTrades.int2ObjectEntrySet().forEach(e -> newTrades.put(e.getIntKey(), e.getValue().toArray(new ITrade[0])));
|
||||
VillagerTrades.VILLAGER_DEFAULT_TRADES.put(prof, newTrades);
|
||||
VillagerTrades.TRADES.put(prof, newTrades);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -52,7 +52,7 @@ public final class TimeValues
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getString()
|
||||
public String getSerializedName()
|
||||
{
|
||||
return "identity";
|
||||
}
|
||||
@@ -244,7 +244,7 @@ public final class TimeValues
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getString()
|
||||
public String getSerializedName()
|
||||
{
|
||||
return parameterName;
|
||||
}
|
||||
@@ -346,7 +346,7 @@ public final class TimeValues
|
||||
}
|
||||
else if(parameter instanceof IStringSerializable)
|
||||
{
|
||||
out.value("#" + ((IStringSerializable)parameter).getString());
|
||||
out.value("#" + ((IStringSerializable)parameter).getSerializedName());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -47,7 +47,7 @@ public class VanillaBrewingRecipe implements IBrewingRecipe {
|
||||
@Override
|
||||
public boolean isIngredient(ItemStack stack)
|
||||
{
|
||||
return PotionBrewing.isReagent(stack);
|
||||
return PotionBrewing.isIngredient(stack);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -60,7 +60,7 @@ public class VanillaBrewingRecipe implements IBrewingRecipe {
|
||||
{
|
||||
if (!input.isEmpty() && !ingredient.isEmpty() && isIngredient(ingredient))
|
||||
{
|
||||
ItemStack result = PotionBrewing.doReaction(ingredient, input);
|
||||
ItemStack result = PotionBrewing.mix(ingredient, input);
|
||||
if (result != input)
|
||||
{
|
||||
return result;
|
||||
|
||||
@@ -57,13 +57,13 @@ public class CompoundIngredient extends Ingredient
|
||||
|
||||
@Override
|
||||
@Nonnull
|
||||
public ItemStack[] getMatchingStacks()
|
||||
public ItemStack[] getItems()
|
||||
{
|
||||
if (stacks == null)
|
||||
{
|
||||
List<ItemStack> tmp = Lists.newArrayList();
|
||||
for (Ingredient child : children)
|
||||
Collections.addAll(tmp, child.getMatchingStacks());
|
||||
Collections.addAll(tmp, child.getItems());
|
||||
stacks = tmp.toArray(new ItemStack[tmp.size()]);
|
||||
|
||||
}
|
||||
@@ -72,14 +72,14 @@ public class CompoundIngredient extends Ingredient
|
||||
|
||||
@Override
|
||||
@Nonnull
|
||||
public IntList getValidItemStacksPacked()
|
||||
public IntList getStackingIds()
|
||||
{
|
||||
//TODO: Add a child.isInvalid()?
|
||||
if (this.itemIds == null)
|
||||
{
|
||||
this.itemIds = new IntArrayList();
|
||||
for (Ingredient child : children)
|
||||
this.itemIds.addAll(child.getValidItemStacksPacked());
|
||||
this.itemIds.addAll(child.getStackingIds());
|
||||
this.itemIds.sort(IntComparators.NATURAL_COMPARATOR);
|
||||
}
|
||||
|
||||
@@ -122,24 +122,24 @@ public class CompoundIngredient extends Ingredient
|
||||
}
|
||||
|
||||
@Override
|
||||
public JsonElement serialize()
|
||||
public JsonElement toJson()
|
||||
{
|
||||
if (this.children.size() == 1)
|
||||
{
|
||||
return this.children.get(0).serialize();
|
||||
return this.children.get(0).toJson();
|
||||
}
|
||||
else
|
||||
{
|
||||
JsonArray json = new JsonArray();
|
||||
this.children.stream().forEach(e -> json.add(e.serialize()));
|
||||
this.children.stream().forEach(e -> json.add(e.toJson()));
|
||||
return json;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasNoMatchingItems()
|
||||
public boolean isEmpty()
|
||||
{
|
||||
return getMatchingStacks().length == 0;
|
||||
return getItems().length == 0;
|
||||
}
|
||||
|
||||
public static class Serializer implements IIngredientSerializer<CompoundIngredient>
|
||||
@@ -149,7 +149,7 @@ public class CompoundIngredient extends Ingredient
|
||||
@Override
|
||||
public CompoundIngredient parse(PacketBuffer buffer)
|
||||
{
|
||||
return new CompoundIngredient(Stream.generate(() -> Ingredient.read(buffer)).limit(buffer.readVarInt()).collect(Collectors.toList()));
|
||||
return new CompoundIngredient(Stream.generate(() -> Ingredient.fromNetwork(buffer)).limit(buffer.readVarInt()).collect(Collectors.toList()));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -162,7 +162,7 @@ public class CompoundIngredient extends Ingredient
|
||||
public void write(PacketBuffer buffer, CompoundIngredient ingredient)
|
||||
{
|
||||
buffer.writeVarInt(ingredient.children.size());
|
||||
ingredient.children.forEach(c -> c.write(buffer));
|
||||
ingredient.children.forEach(c -> c.toNetwork(buffer));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -55,7 +55,7 @@ public class ConditionalAdvancement
|
||||
*/
|
||||
@Nullable
|
||||
public static JsonObject processConditional(JsonObject json) {
|
||||
JsonArray entries = JSONUtils.getJsonArray(json, "advancements", null);
|
||||
JsonArray entries = JSONUtils.getAsJsonArray(json, "advancements", null);
|
||||
if (entries == null)
|
||||
{
|
||||
return CraftingHelper.processConditions(json, "conditions") ? json : null;
|
||||
@@ -66,8 +66,8 @@ public class ConditionalAdvancement
|
||||
{
|
||||
if (!ele.isJsonObject())
|
||||
throw new JsonSyntaxException("Invalid advancement entry at index " + idx + " Must be JsonObject");
|
||||
if (CraftingHelper.processConditions(JSONUtils.getJsonArray(ele.getAsJsonObject(), "conditions")))
|
||||
return JSONUtils.getJsonObject(ele.getAsJsonObject(), "advancement");
|
||||
if (CraftingHelper.processConditions(JSONUtils.getAsJsonArray(ele.getAsJsonObject(), "conditions")))
|
||||
return JSONUtils.getAsJsonObject(ele.getAsJsonObject(), "advancement");
|
||||
idx++;
|
||||
}
|
||||
return null;
|
||||
@@ -99,12 +99,12 @@ public class ConditionalAdvancement
|
||||
|
||||
public Builder addAdvancement(Advancement.Builder advancement)
|
||||
{
|
||||
return addAdvancement(advancement::serialize);
|
||||
return addAdvancement(advancement::serializeToJson);
|
||||
}
|
||||
|
||||
public Builder addAdvancement(IFinishedRecipe fromRecipe)
|
||||
{
|
||||
return addAdvancement(fromRecipe::getAdvancementJson);
|
||||
return addAdvancement(fromRecipe::serializeAdvancement);
|
||||
}
|
||||
|
||||
private Builder addAdvancement(Supplier<JsonElement> jsonSupplier)
|
||||
|
||||
@@ -81,24 +81,24 @@ public class ConditionalRecipe
|
||||
|
||||
@SuppressWarnings("unchecked") // We return a nested one, so we can't know what type it is.
|
||||
@Override
|
||||
public T read(ResourceLocation recipeId, JsonObject json)
|
||||
public T fromJson(ResourceLocation recipeId, JsonObject json)
|
||||
{
|
||||
JsonArray items = JSONUtils.getJsonArray(json, "recipes");
|
||||
JsonArray items = JSONUtils.getAsJsonArray(json, "recipes");
|
||||
int idx = 0;
|
||||
for (JsonElement ele : items)
|
||||
{
|
||||
if (!ele.isJsonObject())
|
||||
throw new JsonSyntaxException("Invalid recipes entry at index " + idx + " Must be JsonObject");
|
||||
if (CraftingHelper.processConditions(JSONUtils.getJsonArray(ele.getAsJsonObject(), "conditions")))
|
||||
return (T)RecipeManager.deserializeRecipe(recipeId, JSONUtils.getJsonObject(ele.getAsJsonObject(), "recipe"));
|
||||
if (CraftingHelper.processConditions(JSONUtils.getAsJsonArray(ele.getAsJsonObject(), "conditions")))
|
||||
return (T)RecipeManager.fromJson(recipeId, JSONUtils.getAsJsonObject(ele.getAsJsonObject(), "recipe"));
|
||||
idx++;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
//Should never get here as we return one of the recipes we wrap.
|
||||
@Override public T read(ResourceLocation recipeId, PacketBuffer buffer) { return null; }
|
||||
@Override public void write(PacketBuffer buffer, T recipe) {}
|
||||
@Override public T fromNetwork(ResourceLocation recipeId, PacketBuffer buffer) { return null; }
|
||||
@Override public void toNetwork(PacketBuffer buffer, T recipe) {}
|
||||
}
|
||||
|
||||
public static class Builder
|
||||
@@ -207,7 +207,7 @@ public class ConditionalRecipe
|
||||
}
|
||||
|
||||
@Override
|
||||
public void serialize(JsonObject json) {
|
||||
public void serializeRecipeData(JsonObject json) {
|
||||
JsonArray array = new JsonArray();
|
||||
json.add("recipes", array);
|
||||
for (int x = 0; x < conditions.size(); x++)
|
||||
@@ -218,30 +218,30 @@ public class ConditionalRecipe
|
||||
for (ICondition c : conditions.get(x))
|
||||
conds.add(CraftingHelper.serialize(c));
|
||||
holder.add("conditions", conds);
|
||||
holder.add("recipe", recipes.get(x).getRecipeJson());
|
||||
holder.add("recipe", recipes.get(x).serializeRecipe());
|
||||
|
||||
array.add(holder);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResourceLocation getID() {
|
||||
public ResourceLocation getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IRecipeSerializer<?> getSerializer()
|
||||
public IRecipeSerializer<?> getType()
|
||||
{
|
||||
return SERIALZIER;
|
||||
}
|
||||
|
||||
@Override
|
||||
public JsonObject getAdvancementJson() {
|
||||
public JsonObject serializeAdvancement() {
|
||||
return adv == null ? null : adv.write();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResourceLocation getAdvancementID() {
|
||||
public ResourceLocation getAdvancementId() {
|
||||
return advId;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -144,7 +144,7 @@ public class CraftingHelper
|
||||
|
||||
JsonObject obj = (JsonObject)json;
|
||||
|
||||
String type = JSONUtils.getString(obj, "type", "minecraft:item");
|
||||
String type = JSONUtils.getAsString(obj, "type", "minecraft:item");
|
||||
if (type.isEmpty())
|
||||
throw new JsonSyntaxException("Ingredient type can not be an empty string");
|
||||
|
||||
@@ -157,7 +157,7 @@ public class CraftingHelper
|
||||
|
||||
public static ItemStack getItemStack(JsonObject json, boolean readNBT)
|
||||
{
|
||||
String itemName = JSONUtils.getString(json, "item");
|
||||
String itemName = JSONUtils.getAsString(json, "item");
|
||||
|
||||
Item item = ForgeRegistries.ITEMS.getValue(new ResourceLocation(itemName));
|
||||
|
||||
@@ -172,9 +172,9 @@ public class CraftingHelper
|
||||
JsonElement element = json.get("nbt");
|
||||
CompoundNBT nbt;
|
||||
if(element.isJsonObject())
|
||||
nbt = JsonToNBT.getTagFromJson(GSON.toJson(element));
|
||||
nbt = JsonToNBT.parseTag(GSON.toJson(element));
|
||||
else
|
||||
nbt = JsonToNBT.getTagFromJson(JSONUtils.getString(element, "nbt"));
|
||||
nbt = JsonToNBT.parseTag(JSONUtils.convertToString(element, "nbt"));
|
||||
|
||||
CompoundNBT tmp = new CompoundNBT();
|
||||
if (nbt.contains("ForgeCaps"))
|
||||
@@ -185,9 +185,9 @@ public class CraftingHelper
|
||||
|
||||
tmp.put("tag", nbt);
|
||||
tmp.putString("id", itemName);
|
||||
tmp.putInt("Count", JSONUtils.getInt(json, "count", 1));
|
||||
tmp.putInt("Count", JSONUtils.getAsInt(json, "count", 1));
|
||||
|
||||
return ItemStack.read(tmp);
|
||||
return ItemStack.of(tmp);
|
||||
}
|
||||
catch (CommandSyntaxException e)
|
||||
{
|
||||
@@ -195,12 +195,12 @@ public class CraftingHelper
|
||||
}
|
||||
}
|
||||
|
||||
return new ItemStack(item, JSONUtils.getInt(json, "count", 1));
|
||||
return new ItemStack(item, JSONUtils.getAsInt(json, "count", 1));
|
||||
}
|
||||
|
||||
public static boolean processConditions(JsonObject json, String memberName)
|
||||
{
|
||||
return !json.has(memberName) || processConditions(JSONUtils.getJsonArray(json, memberName));
|
||||
return !json.has(memberName) || processConditions(JSONUtils.getAsJsonArray(json, memberName));
|
||||
}
|
||||
|
||||
public static boolean processConditions(JsonArray conditions)
|
||||
@@ -219,7 +219,7 @@ public class CraftingHelper
|
||||
|
||||
public static ICondition getCondition(JsonObject json)
|
||||
{
|
||||
ResourceLocation type = new ResourceLocation(JSONUtils.getString(json, "type"));
|
||||
ResourceLocation type = new ResourceLocation(JSONUtils.getAsString(json, "type"));
|
||||
IConditionSerializer<?> serializer = conditions.get(type);
|
||||
if (serializer == null)
|
||||
throw new JsonSyntaxException("Unknown condition type: " + type.toString());
|
||||
|
||||
@@ -45,7 +45,7 @@ public class NBTIngredient extends Ingredient
|
||||
if (input == null)
|
||||
return false;
|
||||
//Can't use areItemStacksEqualUsingNBTShareTag because it compares stack size as well
|
||||
return this.stack.getItem() == input.getItem() && this.stack.getDamage() == input.getDamage() && this.stack.areShareTagsEqual(input);
|
||||
return this.stack.getItem() == input.getItem() && this.stack.getDamageValue() == input.getDamageValue() && this.stack.areShareTagsEqual(input);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -61,7 +61,7 @@ public class NBTIngredient extends Ingredient
|
||||
}
|
||||
|
||||
@Override
|
||||
public JsonElement serialize()
|
||||
public JsonElement toJson()
|
||||
{
|
||||
JsonObject json = new JsonObject();
|
||||
json.addProperty("type", CraftingHelper.getID(Serializer.INSTANCE).toString());
|
||||
@@ -78,7 +78,7 @@ public class NBTIngredient extends Ingredient
|
||||
|
||||
@Override
|
||||
public NBTIngredient parse(PacketBuffer buffer) {
|
||||
return new NBTIngredient(buffer.readItemStack());
|
||||
return new NBTIngredient(buffer.readItem());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -88,7 +88,7 @@ public class NBTIngredient extends Ingredient
|
||||
|
||||
@Override
|
||||
public void write(PacketBuffer buffer, NBTIngredient ingredient) {
|
||||
buffer.writeItemStack(ingredient.stack);
|
||||
buffer.writeItem(ingredient.stack);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -37,7 +37,7 @@ public class StackList implements IItemList
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<ItemStack> getStacks()
|
||||
public Collection<ItemStack> getItems()
|
||||
{
|
||||
return items;
|
||||
}
|
||||
|
||||
@@ -33,20 +33,20 @@ public class VanillaIngredientSerializer implements IIngredientSerializer<Ingred
|
||||
|
||||
public Ingredient parse(PacketBuffer buffer)
|
||||
{
|
||||
return Ingredient.fromItemListStream(Stream.generate(() -> new Ingredient.SingleItemList(buffer.readItemStack())).limit(buffer.readVarInt()));
|
||||
return Ingredient.fromValues(Stream.generate(() -> new Ingredient.SingleItemList(buffer.readItem())).limit(buffer.readVarInt()));
|
||||
}
|
||||
|
||||
public Ingredient parse(JsonObject json)
|
||||
{
|
||||
return Ingredient.fromItemListStream(Stream.of(Ingredient.deserializeItemList(json)));
|
||||
return Ingredient.fromValues(Stream.of(Ingredient.valueFromJson(json)));
|
||||
}
|
||||
|
||||
public void write(PacketBuffer buffer, Ingredient ingredient)
|
||||
{
|
||||
ItemStack[] items = ingredient.getMatchingStacks();
|
||||
ItemStack[] items = ingredient.getItems();
|
||||
buffer.writeVarInt(items.length);
|
||||
|
||||
for (ItemStack stack : items)
|
||||
buffer.writeItemStack(stack);
|
||||
buffer.writeItem(stack);
|
||||
}
|
||||
}
|
||||
@@ -91,7 +91,7 @@ public class AndCondition implements ICondition
|
||||
public AndCondition read(JsonObject json)
|
||||
{
|
||||
List<ICondition> children = new ArrayList<>();
|
||||
for (JsonElement j : JSONUtils.getJsonArray(json, "values"))
|
||||
for (JsonElement j : JSONUtils.getAsJsonArray(json, "values"))
|
||||
{
|
||||
if (!j.isJsonObject())
|
||||
throw new JsonSyntaxException("And condition values must be an array of JsonObjects");
|
||||
|
||||
+1
-1
@@ -76,7 +76,7 @@ public class ItemExistsCondition implements ICondition
|
||||
@Override
|
||||
public ItemExistsCondition read(JsonObject json)
|
||||
{
|
||||
return new ItemExistsCondition(new ResourceLocation(JSONUtils.getString(json, "item")));
|
||||
return new ItemExistsCondition(new ResourceLocation(JSONUtils.getAsString(json, "item")));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -66,7 +66,7 @@ public class ModLoadedCondition implements ICondition
|
||||
@Override
|
||||
public ModLoadedCondition read(JsonObject json)
|
||||
{
|
||||
return new ModLoadedCondition(JSONUtils.getString(json, "modid"));
|
||||
return new ModLoadedCondition(JSONUtils.getAsString(json, "modid"));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -65,7 +65,7 @@ public class NotCondition implements ICondition
|
||||
@Override
|
||||
public NotCondition read(JsonObject json)
|
||||
{
|
||||
return new NotCondition(CraftingHelper.getCondition(JSONUtils.getJsonObject(json, "value")));
|
||||
return new NotCondition(CraftingHelper.getCondition(JSONUtils.getAsJsonObject(json, "value")));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -92,7 +92,7 @@ public class OrCondition implements ICondition
|
||||
public OrCondition read(JsonObject json)
|
||||
{
|
||||
List<ICondition> children = new ArrayList<>();
|
||||
for (JsonElement j : JSONUtils.getJsonArray(json, "values"))
|
||||
for (JsonElement j : JSONUtils.getAsJsonArray(json, "values"))
|
||||
{
|
||||
if (!j.isJsonObject())
|
||||
throw new JsonSyntaxException("Or condition values must be an array of JsonObjects");
|
||||
|
||||
@@ -56,8 +56,8 @@ public class TagEmptyCondition implements ICondition
|
||||
@Override
|
||||
public boolean test()
|
||||
{
|
||||
ITag<Item> tag = TagCollectionManager.getManager().getItemTags().get(tag_name);
|
||||
return tag == null || tag.getAllElements().isEmpty();
|
||||
ITag<Item> tag = TagCollectionManager.getInstance().getItems().getTag(tag_name);
|
||||
return tag == null || tag.getValues().isEmpty();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -79,7 +79,7 @@ public class TagEmptyCondition implements ICondition
|
||||
@Override
|
||||
public TagEmptyCondition read(JsonObject json)
|
||||
{
|
||||
return new TagEmptyCondition(new ResourceLocation(JSONUtils.getString(json, "tag")));
|
||||
return new TagEmptyCondition(new ResourceLocation(JSONUtils.getAsString(json, "tag")));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -108,20 +108,20 @@ public class ExistingFileHelper {
|
||||
public ExistingFileHelper(Collection<Path> existingPacks, Set<String> existingMods, boolean enable) {
|
||||
this.clientResources = new SimpleReloadableResourceManager(ResourcePackType.CLIENT_RESOURCES);
|
||||
this.serverData = new SimpleReloadableResourceManager(ResourcePackType.SERVER_DATA);
|
||||
this.clientResources.addResourcePack(new VanillaPack("minecraft", "realms"));
|
||||
this.serverData.addResourcePack(new VanillaPack("minecraft"));
|
||||
this.clientResources.add(new VanillaPack("minecraft", "realms"));
|
||||
this.serverData.add(new VanillaPack("minecraft"));
|
||||
for (Path existing : existingPacks) {
|
||||
File file = existing.toFile();
|
||||
IResourcePack pack = file.isDirectory() ? new FolderPack(file) : new FilePack(file);
|
||||
this.clientResources.addResourcePack(pack);
|
||||
this.serverData.addResourcePack(pack);
|
||||
this.clientResources.add(pack);
|
||||
this.serverData.add(pack);
|
||||
}
|
||||
for (String existingMod : existingMods) {
|
||||
ModFileInfo modFileInfo = ModList.get().getModFileById(existingMod);
|
||||
if (modFileInfo != null) {
|
||||
IResourcePack pack = new ModFileResourcePack(modFileInfo.getFile());
|
||||
this.clientResources.addResourcePack(pack);
|
||||
this.serverData.addResourcePack(pack);
|
||||
this.clientResources.add(pack);
|
||||
this.serverData.add(pack);
|
||||
}
|
||||
}
|
||||
this.enable = enable;
|
||||
|
||||
@@ -44,55 +44,55 @@ public class ForgeBlockTagsProvider extends BlockTagsProvider
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public void registerTags()
|
||||
public void addTags()
|
||||
{
|
||||
getOrCreateBuilder(CHESTS).addTags(CHESTS_ENDER, CHESTS_TRAPPED, CHESTS_WOODEN);
|
||||
getOrCreateBuilder(CHESTS_ENDER).add(Blocks.ENDER_CHEST);
|
||||
getOrCreateBuilder(CHESTS_TRAPPED).add(Blocks.TRAPPED_CHEST);
|
||||
getOrCreateBuilder(CHESTS_WOODEN).add(Blocks.CHEST, Blocks.TRAPPED_CHEST);
|
||||
getOrCreateBuilder(COBBLESTONE).add(Blocks.COBBLESTONE, Blocks.INFESTED_COBBLESTONE, Blocks.MOSSY_COBBLESTONE);
|
||||
getOrCreateBuilder(DIRT).add(Blocks.DIRT, Blocks.GRASS_BLOCK, Blocks.COARSE_DIRT, Blocks.PODZOL, Blocks.MYCELIUM);
|
||||
getOrCreateBuilder(END_STONES).add(Blocks.END_STONE);
|
||||
getOrCreateBuilder(ENDERMAN_PLACE_ON_BLACKLIST);
|
||||
getOrCreateBuilder(FENCE_GATES).addTags(FENCE_GATES_WOODEN);
|
||||
getOrCreateBuilder(FENCE_GATES_WOODEN).add(Blocks.OAK_FENCE_GATE, Blocks.SPRUCE_FENCE_GATE, Blocks.BIRCH_FENCE_GATE, Blocks.JUNGLE_FENCE_GATE, Blocks.ACACIA_FENCE_GATE, Blocks.DARK_OAK_FENCE_GATE, Blocks.CRIMSON_FENCE_GATE, Blocks.WARPED_FENCE_GATE);
|
||||
getOrCreateBuilder(FENCES).addTags(FENCES_NETHER_BRICK, FENCES_WOODEN);
|
||||
getOrCreateBuilder(FENCES_NETHER_BRICK).add(Blocks.NETHER_BRICK_FENCE);
|
||||
getOrCreateBuilder(FENCES_WOODEN).add(Blocks.OAK_FENCE, Blocks.SPRUCE_FENCE, Blocks.BIRCH_FENCE, Blocks.JUNGLE_FENCE, Blocks.ACACIA_FENCE, Blocks.DARK_OAK_FENCE, Blocks.CRIMSON_FENCE, Blocks.WARPED_FENCE);
|
||||
getOrCreateBuilder(GLASS).addTags(GLASS_COLORLESS, STAINED_GLASS);
|
||||
getOrCreateBuilder(GLASS_COLORLESS).add(Blocks.GLASS);
|
||||
addColored(getOrCreateBuilder(STAINED_GLASS)::add, GLASS, "{color}_stained_glass");
|
||||
getOrCreateBuilder(GLASS_PANES).addTags(GLASS_PANES_COLORLESS, STAINED_GLASS_PANES);
|
||||
getOrCreateBuilder(GLASS_PANES_COLORLESS).add(Blocks.GLASS_PANE);
|
||||
addColored(getOrCreateBuilder(STAINED_GLASS_PANES)::add, GLASS_PANES, "{color}_stained_glass_pane");
|
||||
getOrCreateBuilder(GRAVEL).add(Blocks.GRAVEL);
|
||||
getOrCreateBuilder(NETHERRACK).add(Blocks.NETHERRACK);
|
||||
getOrCreateBuilder(OBSIDIAN).add(Blocks.OBSIDIAN);
|
||||
getOrCreateBuilder(ORES).addTags(ORES_COAL, ORES_DIAMOND, ORES_EMERALD, ORES_GOLD, ORES_IRON, ORES_LAPIS, ORES_REDSTONE, ORES_QUARTZ, ORES_NETHERITE_SCRAP);
|
||||
getOrCreateBuilder(ORES_COAL).add(Blocks.COAL_ORE);
|
||||
getOrCreateBuilder(ORES_DIAMOND).add(Blocks.DIAMOND_ORE);
|
||||
getOrCreateBuilder(ORES_EMERALD).add(Blocks.EMERALD_ORE);
|
||||
getOrCreateBuilder(ORES_GOLD).addTag(BlockTags.GOLD_ORES);
|
||||
getOrCreateBuilder(ORES_IRON).add(Blocks.IRON_ORE);
|
||||
getOrCreateBuilder(ORES_LAPIS).add(Blocks.LAPIS_ORE);
|
||||
getOrCreateBuilder(ORES_QUARTZ).add(Blocks.NETHER_QUARTZ_ORE);
|
||||
getOrCreateBuilder(ORES_REDSTONE).add(Blocks.REDSTONE_ORE);
|
||||
getOrCreateBuilder(ORES_NETHERITE_SCRAP).add(Blocks.ANCIENT_DEBRIS);
|
||||
getOrCreateBuilder(SAND).addTags(SAND_COLORLESS, SAND_RED);
|
||||
getOrCreateBuilder(SAND_COLORLESS).add(Blocks.SAND);
|
||||
getOrCreateBuilder(SAND_RED).add(Blocks.RED_SAND);
|
||||
getOrCreateBuilder(SANDSTONE).add(Blocks.SANDSTONE, Blocks.CUT_SANDSTONE, Blocks.CHISELED_SANDSTONE, Blocks.SMOOTH_SANDSTONE, Blocks.RED_SANDSTONE, Blocks.CUT_RED_SANDSTONE, Blocks.CHISELED_RED_SANDSTONE, Blocks.SMOOTH_RED_SANDSTONE);
|
||||
getOrCreateBuilder(STONE).add(Blocks.ANDESITE, Blocks.DIORITE, Blocks.GRANITE, Blocks.INFESTED_STONE, Blocks.STONE, Blocks.POLISHED_ANDESITE, Blocks.POLISHED_DIORITE, Blocks.POLISHED_GRANITE);
|
||||
getOrCreateBuilder(STORAGE_BLOCKS).addTags(STORAGE_BLOCKS_COAL, STORAGE_BLOCKS_DIAMOND, STORAGE_BLOCKS_EMERALD, STORAGE_BLOCKS_GOLD, STORAGE_BLOCKS_IRON, STORAGE_BLOCKS_LAPIS, STORAGE_BLOCKS_QUARTZ, STORAGE_BLOCKS_REDSTONE, STORAGE_BLOCKS_NETHERITE);
|
||||
getOrCreateBuilder(STORAGE_BLOCKS_COAL).add(Blocks.COAL_BLOCK);
|
||||
getOrCreateBuilder(STORAGE_BLOCKS_DIAMOND).add(Blocks.DIAMOND_BLOCK);
|
||||
getOrCreateBuilder(STORAGE_BLOCKS_EMERALD).add(Blocks.EMERALD_BLOCK);
|
||||
getOrCreateBuilder(STORAGE_BLOCKS_GOLD).add(Blocks.GOLD_BLOCK);
|
||||
getOrCreateBuilder(STORAGE_BLOCKS_IRON).add(Blocks.IRON_BLOCK);
|
||||
getOrCreateBuilder(STORAGE_BLOCKS_LAPIS).add(Blocks.LAPIS_BLOCK);
|
||||
getOrCreateBuilder(STORAGE_BLOCKS_QUARTZ).add(Blocks.QUARTZ_BLOCK);
|
||||
getOrCreateBuilder(STORAGE_BLOCKS_REDSTONE).add(Blocks.REDSTONE_BLOCK);
|
||||
getOrCreateBuilder(STORAGE_BLOCKS_NETHERITE).add(Blocks.NETHERITE_BLOCK);
|
||||
tag(CHESTS).addTags(CHESTS_ENDER, CHESTS_TRAPPED, CHESTS_WOODEN);
|
||||
tag(CHESTS_ENDER).add(Blocks.ENDER_CHEST);
|
||||
tag(CHESTS_TRAPPED).add(Blocks.TRAPPED_CHEST);
|
||||
tag(CHESTS_WOODEN).add(Blocks.CHEST, Blocks.TRAPPED_CHEST);
|
||||
tag(COBBLESTONE).add(Blocks.COBBLESTONE, Blocks.INFESTED_COBBLESTONE, Blocks.MOSSY_COBBLESTONE);
|
||||
tag(DIRT).add(Blocks.DIRT, Blocks.GRASS_BLOCK, Blocks.COARSE_DIRT, Blocks.PODZOL, Blocks.MYCELIUM);
|
||||
tag(END_STONES).add(Blocks.END_STONE);
|
||||
tag(ENDERMAN_PLACE_ON_BLACKLIST);
|
||||
tag(FENCE_GATES).addTags(FENCE_GATES_WOODEN);
|
||||
tag(FENCE_GATES_WOODEN).add(Blocks.OAK_FENCE_GATE, Blocks.SPRUCE_FENCE_GATE, Blocks.BIRCH_FENCE_GATE, Blocks.JUNGLE_FENCE_GATE, Blocks.ACACIA_FENCE_GATE, Blocks.DARK_OAK_FENCE_GATE, Blocks.CRIMSON_FENCE_GATE, Blocks.WARPED_FENCE_GATE);
|
||||
tag(FENCES).addTags(FENCES_NETHER_BRICK, FENCES_WOODEN);
|
||||
tag(FENCES_NETHER_BRICK).add(Blocks.NETHER_BRICK_FENCE);
|
||||
tag(FENCES_WOODEN).add(Blocks.OAK_FENCE, Blocks.SPRUCE_FENCE, Blocks.BIRCH_FENCE, Blocks.JUNGLE_FENCE, Blocks.ACACIA_FENCE, Blocks.DARK_OAK_FENCE, Blocks.CRIMSON_FENCE, Blocks.WARPED_FENCE);
|
||||
tag(GLASS).addTags(GLASS_COLORLESS, STAINED_GLASS);
|
||||
tag(GLASS_COLORLESS).add(Blocks.GLASS);
|
||||
addColored(tag(STAINED_GLASS)::add, GLASS, "{color}_stained_glass");
|
||||
tag(GLASS_PANES).addTags(GLASS_PANES_COLORLESS, STAINED_GLASS_PANES);
|
||||
tag(GLASS_PANES_COLORLESS).add(Blocks.GLASS_PANE);
|
||||
addColored(tag(STAINED_GLASS_PANES)::add, GLASS_PANES, "{color}_stained_glass_pane");
|
||||
tag(GRAVEL).add(Blocks.GRAVEL);
|
||||
tag(NETHERRACK).add(Blocks.NETHERRACK);
|
||||
tag(OBSIDIAN).add(Blocks.OBSIDIAN);
|
||||
tag(ORES).addTags(ORES_COAL, ORES_DIAMOND, ORES_EMERALD, ORES_GOLD, ORES_IRON, ORES_LAPIS, ORES_REDSTONE, ORES_QUARTZ, ORES_NETHERITE_SCRAP);
|
||||
tag(ORES_COAL).add(Blocks.COAL_ORE);
|
||||
tag(ORES_DIAMOND).add(Blocks.DIAMOND_ORE);
|
||||
tag(ORES_EMERALD).add(Blocks.EMERALD_ORE);
|
||||
tag(ORES_GOLD).addTag(BlockTags.GOLD_ORES);
|
||||
tag(ORES_IRON).add(Blocks.IRON_ORE);
|
||||
tag(ORES_LAPIS).add(Blocks.LAPIS_ORE);
|
||||
tag(ORES_QUARTZ).add(Blocks.NETHER_QUARTZ_ORE);
|
||||
tag(ORES_REDSTONE).add(Blocks.REDSTONE_ORE);
|
||||
tag(ORES_NETHERITE_SCRAP).add(Blocks.ANCIENT_DEBRIS);
|
||||
tag(SAND).addTags(SAND_COLORLESS, SAND_RED);
|
||||
tag(SAND_COLORLESS).add(Blocks.SAND);
|
||||
tag(SAND_RED).add(Blocks.RED_SAND);
|
||||
tag(SANDSTONE).add(Blocks.SANDSTONE, Blocks.CUT_SANDSTONE, Blocks.CHISELED_SANDSTONE, Blocks.SMOOTH_SANDSTONE, Blocks.RED_SANDSTONE, Blocks.CUT_RED_SANDSTONE, Blocks.CHISELED_RED_SANDSTONE, Blocks.SMOOTH_RED_SANDSTONE);
|
||||
tag(STONE).add(Blocks.ANDESITE, Blocks.DIORITE, Blocks.GRANITE, Blocks.INFESTED_STONE, Blocks.STONE, Blocks.POLISHED_ANDESITE, Blocks.POLISHED_DIORITE, Blocks.POLISHED_GRANITE);
|
||||
tag(STORAGE_BLOCKS).addTags(STORAGE_BLOCKS_COAL, STORAGE_BLOCKS_DIAMOND, STORAGE_BLOCKS_EMERALD, STORAGE_BLOCKS_GOLD, STORAGE_BLOCKS_IRON, STORAGE_BLOCKS_LAPIS, STORAGE_BLOCKS_QUARTZ, STORAGE_BLOCKS_REDSTONE, STORAGE_BLOCKS_NETHERITE);
|
||||
tag(STORAGE_BLOCKS_COAL).add(Blocks.COAL_BLOCK);
|
||||
tag(STORAGE_BLOCKS_DIAMOND).add(Blocks.DIAMOND_BLOCK);
|
||||
tag(STORAGE_BLOCKS_EMERALD).add(Blocks.EMERALD_BLOCK);
|
||||
tag(STORAGE_BLOCKS_GOLD).add(Blocks.GOLD_BLOCK);
|
||||
tag(STORAGE_BLOCKS_IRON).add(Blocks.IRON_BLOCK);
|
||||
tag(STORAGE_BLOCKS_LAPIS).add(Blocks.LAPIS_BLOCK);
|
||||
tag(STORAGE_BLOCKS_QUARTZ).add(Blocks.QUARTZ_BLOCK);
|
||||
tag(STORAGE_BLOCKS_REDSTONE).add(Blocks.REDSTONE_BLOCK);
|
||||
tag(STORAGE_BLOCKS_NETHERITE).add(Blocks.NETHERITE_BLOCK);
|
||||
}
|
||||
|
||||
private void addColored(Consumer<Block> consumer, ITag.INamedTag<Block> group, String pattern)
|
||||
@@ -100,12 +100,12 @@ public class ForgeBlockTagsProvider extends BlockTagsProvider
|
||||
String prefix = group.getName().getPath().toUpperCase(Locale.ENGLISH) + '_';
|
||||
for (DyeColor color : DyeColor.values())
|
||||
{
|
||||
ResourceLocation key = new ResourceLocation("minecraft", pattern.replace("{color}", color.getTranslationKey()));
|
||||
ITag.INamedTag<Block> tag = getForgeTag(prefix + color.getTranslationKey());
|
||||
ResourceLocation key = new ResourceLocation("minecraft", pattern.replace("{color}", color.getName()));
|
||||
ITag.INamedTag<Block> tag = getForgeTag(prefix + color.getName());
|
||||
Block block = ForgeRegistries.BLOCKS.getValue(key);
|
||||
if (block == null || block == Blocks.AIR)
|
||||
throw new IllegalStateException("Unknown vanilla block: " + key.toString());
|
||||
getOrCreateBuilder(tag).add(block);
|
||||
tag(tag).add(block);
|
||||
consumer.accept(block);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,9 +33,9 @@ public class ForgeFluidTagsProvider extends FluidTagsProvider
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerTags()
|
||||
public void addTags()
|
||||
{
|
||||
getOrCreateBuilder(MILK).addOptional(ForgeMod.MILK.getId()).addOptional(ForgeMod.FLOWING_MILK.getId());
|
||||
tag(MILK).addOptional(ForgeMod.MILK.getId()).addOptional(ForgeMod.FLOWING_MILK.getId());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -43,61 +43,61 @@ public class ForgeItemTagsProvider extends ItemTagsProvider
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public void registerTags()
|
||||
public void addTags()
|
||||
{
|
||||
getOrCreateBuilder(Tags.Items.BONES).add(Items.BONE);
|
||||
getOrCreateBuilder(Tags.Items.BOOKSHELVES).add(Items.BOOKSHELF);
|
||||
tag(Tags.Items.BONES).add(Items.BONE);
|
||||
tag(Tags.Items.BOOKSHELVES).add(Items.BOOKSHELF);
|
||||
copy(Tags.Blocks.CHESTS, Tags.Items.CHESTS);
|
||||
copy(Tags.Blocks.CHESTS_ENDER, Tags.Items.CHESTS_ENDER);
|
||||
copy(Tags.Blocks.CHESTS_TRAPPED, Tags.Items.CHESTS_TRAPPED);
|
||||
copy(Tags.Blocks.CHESTS_WOODEN, Tags.Items.CHESTS_WOODEN);
|
||||
copy(Tags.Blocks.COBBLESTONE, Tags.Items.COBBLESTONE);
|
||||
getOrCreateBuilder(Tags.Items.CROPS).addTags(Tags.Items.CROPS_BEETROOT, Tags.Items.CROPS_CARROT, Tags.Items.CROPS_NETHER_WART, Tags.Items.CROPS_POTATO, Tags.Items.CROPS_WHEAT);
|
||||
getOrCreateBuilder(Tags.Items.CROPS_BEETROOT).add(Items.BEETROOT);
|
||||
getOrCreateBuilder(Tags.Items.CROPS_CARROT).add(Items.CARROT);
|
||||
getOrCreateBuilder(Tags.Items.CROPS_NETHER_WART).add(Items.NETHER_WART);
|
||||
getOrCreateBuilder(Tags.Items.CROPS_POTATO).add(Items.POTATO);
|
||||
getOrCreateBuilder(Tags.Items.CROPS_WHEAT).add(Items.WHEAT);
|
||||
getOrCreateBuilder(Tags.Items.DUSTS).addTags(Tags.Items.DUSTS_GLOWSTONE, Tags.Items.DUSTS_PRISMARINE, Tags.Items.DUSTS_REDSTONE);
|
||||
getOrCreateBuilder(Tags.Items.DUSTS_GLOWSTONE).add(Items.GLOWSTONE_DUST);
|
||||
getOrCreateBuilder(Tags.Items.DUSTS_PRISMARINE).add(Items.PRISMARINE_SHARD);
|
||||
getOrCreateBuilder(Tags.Items.DUSTS_REDSTONE).add(Items.REDSTONE);
|
||||
addColored(getOrCreateBuilder(Tags.Items.DYES)::addTags, Tags.Items.DYES, "{color}_dye");
|
||||
getOrCreateBuilder(Tags.Items.EGGS).add(Items.EGG);
|
||||
tag(Tags.Items.CROPS).addTags(Tags.Items.CROPS_BEETROOT, Tags.Items.CROPS_CARROT, Tags.Items.CROPS_NETHER_WART, Tags.Items.CROPS_POTATO, Tags.Items.CROPS_WHEAT);
|
||||
tag(Tags.Items.CROPS_BEETROOT).add(Items.BEETROOT);
|
||||
tag(Tags.Items.CROPS_CARROT).add(Items.CARROT);
|
||||
tag(Tags.Items.CROPS_NETHER_WART).add(Items.NETHER_WART);
|
||||
tag(Tags.Items.CROPS_POTATO).add(Items.POTATO);
|
||||
tag(Tags.Items.CROPS_WHEAT).add(Items.WHEAT);
|
||||
tag(Tags.Items.DUSTS).addTags(Tags.Items.DUSTS_GLOWSTONE, Tags.Items.DUSTS_PRISMARINE, Tags.Items.DUSTS_REDSTONE);
|
||||
tag(Tags.Items.DUSTS_GLOWSTONE).add(Items.GLOWSTONE_DUST);
|
||||
tag(Tags.Items.DUSTS_PRISMARINE).add(Items.PRISMARINE_SHARD);
|
||||
tag(Tags.Items.DUSTS_REDSTONE).add(Items.REDSTONE);
|
||||
addColored(tag(Tags.Items.DYES)::addTags, Tags.Items.DYES, "{color}_dye");
|
||||
tag(Tags.Items.EGGS).add(Items.EGG);
|
||||
copy(Tags.Blocks.END_STONES, Tags.Items.END_STONES);
|
||||
getOrCreateBuilder(Tags.Items.ENDER_PEARLS).add(Items.ENDER_PEARL);
|
||||
getOrCreateBuilder(Tags.Items.FEATHERS).add(Items.FEATHER);
|
||||
tag(Tags.Items.ENDER_PEARLS).add(Items.ENDER_PEARL);
|
||||
tag(Tags.Items.FEATHERS).add(Items.FEATHER);
|
||||
copy(Tags.Blocks.FENCE_GATES, Tags.Items.FENCE_GATES);
|
||||
copy(Tags.Blocks.FENCE_GATES_WOODEN, Tags.Items.FENCE_GATES_WOODEN);
|
||||
copy(Tags.Blocks.FENCES, Tags.Items.FENCES);
|
||||
copy(Tags.Blocks.FENCES_NETHER_BRICK, Tags.Items.FENCES_NETHER_BRICK);
|
||||
copy(Tags.Blocks.FENCES_WOODEN, Tags.Items.FENCES_WOODEN);
|
||||
getOrCreateBuilder(Tags.Items.GEMS).addTags(Tags.Items.GEMS_DIAMOND, Tags.Items.GEMS_EMERALD, Tags.Items.GEMS_LAPIS, Tags.Items.GEMS_PRISMARINE, Tags.Items.GEMS_QUARTZ);
|
||||
getOrCreateBuilder(Tags.Items.GEMS_DIAMOND).add(Items.DIAMOND);
|
||||
getOrCreateBuilder(Tags.Items.GEMS_EMERALD).add(Items.EMERALD);
|
||||
getOrCreateBuilder(Tags.Items.GEMS_LAPIS).add(Items.LAPIS_LAZULI);
|
||||
getOrCreateBuilder(Tags.Items.GEMS_PRISMARINE).add(Items.PRISMARINE_CRYSTALS);
|
||||
getOrCreateBuilder(Tags.Items.GEMS_QUARTZ).add(Items.QUARTZ);
|
||||
tag(Tags.Items.GEMS).addTags(Tags.Items.GEMS_DIAMOND, Tags.Items.GEMS_EMERALD, Tags.Items.GEMS_LAPIS, Tags.Items.GEMS_PRISMARINE, Tags.Items.GEMS_QUARTZ);
|
||||
tag(Tags.Items.GEMS_DIAMOND).add(Items.DIAMOND);
|
||||
tag(Tags.Items.GEMS_EMERALD).add(Items.EMERALD);
|
||||
tag(Tags.Items.GEMS_LAPIS).add(Items.LAPIS_LAZULI);
|
||||
tag(Tags.Items.GEMS_PRISMARINE).add(Items.PRISMARINE_CRYSTALS);
|
||||
tag(Tags.Items.GEMS_QUARTZ).add(Items.QUARTZ);
|
||||
copy(Tags.Blocks.GLASS, Tags.Items.GLASS);
|
||||
func_240521_a_Colored(Tags.Blocks.GLASS, Tags.Items.GLASS);
|
||||
copy(Tags.Blocks.GLASS_PANES, Tags.Items.GLASS_PANES);
|
||||
func_240521_a_Colored(Tags.Blocks.GLASS_PANES, Tags.Items.GLASS_PANES);
|
||||
copy(Tags.Blocks.GRAVEL, Tags.Items.GRAVEL);
|
||||
getOrCreateBuilder(Tags.Items.GUNPOWDER).add(Items.GUNPOWDER);
|
||||
getOrCreateBuilder(Tags.Items.HEADS).add(Items.CREEPER_HEAD, Items.DRAGON_HEAD, Items.PLAYER_HEAD, Items.SKELETON_SKULL, Items.WITHER_SKELETON_SKULL, Items.ZOMBIE_HEAD);
|
||||
getOrCreateBuilder(Tags.Items.INGOTS).addTags(Tags.Items.INGOTS_IRON, Tags.Items.INGOTS_GOLD, Tags.Items.INGOTS_BRICK, Tags.Items.INGOTS_NETHER_BRICK, Tags.Items.INGOTS_NETHERITE);
|
||||
getOrCreateBuilder(Tags.Items.INGOTS_BRICK).add(Items.BRICK);
|
||||
getOrCreateBuilder(Tags.Items.INGOTS_GOLD).add(Items.GOLD_INGOT);
|
||||
getOrCreateBuilder(Tags.Items.INGOTS_IRON).add(Items.IRON_INGOT);
|
||||
getOrCreateBuilder(Tags.Items.INGOTS_NETHERITE).add(Items.NETHERITE_INGOT);
|
||||
getOrCreateBuilder(Tags.Items.INGOTS_NETHER_BRICK).add(Items.NETHER_BRICK);
|
||||
getOrCreateBuilder(Tags.Items.LEATHER).add(Items.LEATHER);
|
||||
getOrCreateBuilder(Tags.Items.MUSHROOMS).add(Items.BROWN_MUSHROOM, Items.RED_MUSHROOM);
|
||||
getOrCreateBuilder(Tags.Items.NETHER_STARS).add(Items.NETHER_STAR);
|
||||
tag(Tags.Items.GUNPOWDER).add(Items.GUNPOWDER);
|
||||
tag(Tags.Items.HEADS).add(Items.CREEPER_HEAD, Items.DRAGON_HEAD, Items.PLAYER_HEAD, Items.SKELETON_SKULL, Items.WITHER_SKELETON_SKULL, Items.ZOMBIE_HEAD);
|
||||
tag(Tags.Items.INGOTS).addTags(Tags.Items.INGOTS_IRON, Tags.Items.INGOTS_GOLD, Tags.Items.INGOTS_BRICK, Tags.Items.INGOTS_NETHER_BRICK, Tags.Items.INGOTS_NETHERITE);
|
||||
tag(Tags.Items.INGOTS_BRICK).add(Items.BRICK);
|
||||
tag(Tags.Items.INGOTS_GOLD).add(Items.GOLD_INGOT);
|
||||
tag(Tags.Items.INGOTS_IRON).add(Items.IRON_INGOT);
|
||||
tag(Tags.Items.INGOTS_NETHERITE).add(Items.NETHERITE_INGOT);
|
||||
tag(Tags.Items.INGOTS_NETHER_BRICK).add(Items.NETHER_BRICK);
|
||||
tag(Tags.Items.LEATHER).add(Items.LEATHER);
|
||||
tag(Tags.Items.MUSHROOMS).add(Items.BROWN_MUSHROOM, Items.RED_MUSHROOM);
|
||||
tag(Tags.Items.NETHER_STARS).add(Items.NETHER_STAR);
|
||||
copy(Tags.Blocks.NETHERRACK, Tags.Items.NETHERRACK);
|
||||
getOrCreateBuilder(Tags.Items.NUGGETS).addTags(Tags.Items.NUGGETS_IRON, Tags.Items.NUGGETS_GOLD);
|
||||
getOrCreateBuilder(Tags.Items.NUGGETS_IRON).add(Items.IRON_NUGGET);
|
||||
getOrCreateBuilder(Tags.Items.NUGGETS_GOLD).add(Items.GOLD_NUGGET);
|
||||
tag(Tags.Items.NUGGETS).addTags(Tags.Items.NUGGETS_IRON, Tags.Items.NUGGETS_GOLD);
|
||||
tag(Tags.Items.NUGGETS_IRON).add(Items.IRON_NUGGET);
|
||||
tag(Tags.Items.NUGGETS_GOLD).add(Items.GOLD_NUGGET);
|
||||
copy(Tags.Blocks.OBSIDIAN, Tags.Items.OBSIDIAN);
|
||||
copy(Tags.Blocks.ORES, Tags.Items.ORES);
|
||||
copy(Tags.Blocks.ORES_COAL, Tags.Items.ORES_COAL);
|
||||
@@ -109,20 +109,20 @@ public class ForgeItemTagsProvider extends ItemTagsProvider
|
||||
copy(Tags.Blocks.ORES_QUARTZ, Tags.Items.ORES_QUARTZ);
|
||||
copy(Tags.Blocks.ORES_REDSTONE, Tags.Items.ORES_REDSTONE);
|
||||
copy(Tags.Blocks.ORES_NETHERITE_SCRAP, Tags.Items.ORES_NETHERITE_SCRAP);
|
||||
getOrCreateBuilder(Tags.Items.RODS).addTags(Tags.Items.RODS_BLAZE, Tags.Items.RODS_WOODEN);
|
||||
getOrCreateBuilder(Tags.Items.RODS_BLAZE).add(Items.BLAZE_ROD);
|
||||
getOrCreateBuilder(Tags.Items.RODS_WOODEN).add(Items.STICK);
|
||||
tag(Tags.Items.RODS).addTags(Tags.Items.RODS_BLAZE, Tags.Items.RODS_WOODEN);
|
||||
tag(Tags.Items.RODS_BLAZE).add(Items.BLAZE_ROD);
|
||||
tag(Tags.Items.RODS_WOODEN).add(Items.STICK);
|
||||
copy(Tags.Blocks.SAND, Tags.Items.SAND);
|
||||
copy(Tags.Blocks.SAND_COLORLESS, Tags.Items.SAND_COLORLESS);
|
||||
copy(Tags.Blocks.SAND_RED, Tags.Items.SAND_RED);
|
||||
copy(Tags.Blocks.SANDSTONE, Tags.Items.SANDSTONE);
|
||||
getOrCreateBuilder(Tags.Items.SEEDS).addTags(Tags.Items.SEEDS_BEETROOT, Tags.Items.SEEDS_MELON, Tags.Items.SEEDS_PUMPKIN, Tags.Items.SEEDS_WHEAT);
|
||||
getOrCreateBuilder(Tags.Items.SEEDS_BEETROOT).add(Items.BEETROOT_SEEDS);
|
||||
getOrCreateBuilder(Tags.Items.SEEDS_MELON).add(Items.MELON_SEEDS);
|
||||
getOrCreateBuilder(Tags.Items.SEEDS_PUMPKIN).add(Items.PUMPKIN_SEEDS);
|
||||
getOrCreateBuilder(Tags.Items.SEEDS_WHEAT).add(Items.WHEAT_SEEDS);
|
||||
getOrCreateBuilder(Tags.Items.SHEARS).add(Items.SHEARS);
|
||||
getOrCreateBuilder(Tags.Items.SLIMEBALLS).add(Items.SLIME_BALL);
|
||||
tag(Tags.Items.SEEDS).addTags(Tags.Items.SEEDS_BEETROOT, Tags.Items.SEEDS_MELON, Tags.Items.SEEDS_PUMPKIN, Tags.Items.SEEDS_WHEAT);
|
||||
tag(Tags.Items.SEEDS_BEETROOT).add(Items.BEETROOT_SEEDS);
|
||||
tag(Tags.Items.SEEDS_MELON).add(Items.MELON_SEEDS);
|
||||
tag(Tags.Items.SEEDS_PUMPKIN).add(Items.PUMPKIN_SEEDS);
|
||||
tag(Tags.Items.SEEDS_WHEAT).add(Items.WHEAT_SEEDS);
|
||||
tag(Tags.Items.SHEARS).add(Items.SHEARS);
|
||||
tag(Tags.Items.SLIMEBALLS).add(Items.SLIME_BALL);
|
||||
copy(Tags.Blocks.STAINED_GLASS, Tags.Items.STAINED_GLASS);
|
||||
copy(Tags.Blocks.STAINED_GLASS_PANES, Tags.Items.STAINED_GLASS_PANES);
|
||||
copy(Tags.Blocks.STONE, Tags.Items.STONE);
|
||||
@@ -136,7 +136,7 @@ public class ForgeItemTagsProvider extends ItemTagsProvider
|
||||
copy(Tags.Blocks.STORAGE_BLOCKS_QUARTZ, Tags.Items.STORAGE_BLOCKS_QUARTZ);
|
||||
copy(Tags.Blocks.STORAGE_BLOCKS_REDSTONE, Tags.Items.STORAGE_BLOCKS_REDSTONE);
|
||||
copy(Tags.Blocks.STORAGE_BLOCKS_NETHERITE, Tags.Items.STORAGE_BLOCKS_NETHERITE);
|
||||
getOrCreateBuilder(Tags.Items.STRING).add(Items.STRING);
|
||||
tag(Tags.Items.STRING).add(Items.STRING);
|
||||
}
|
||||
|
||||
private void addColored(Consumer<ITag.INamedTag<Item>> consumer, ITag.INamedTag<Item> group, String pattern)
|
||||
@@ -144,12 +144,12 @@ public class ForgeItemTagsProvider extends ItemTagsProvider
|
||||
String prefix = group.getName().getPath().toUpperCase(Locale.ENGLISH) + '_';
|
||||
for (DyeColor color : DyeColor.values())
|
||||
{
|
||||
ResourceLocation key = new ResourceLocation("minecraft", pattern.replace("{color}", color.getTranslationKey()));
|
||||
ITag.INamedTag<Item> tag = getForgeItemTag(prefix + color.getTranslationKey());
|
||||
ResourceLocation key = new ResourceLocation("minecraft", pattern.replace("{color}", color.getName()));
|
||||
ITag.INamedTag<Item> tag = getForgeItemTag(prefix + color.getName());
|
||||
Item item = ForgeRegistries.ITEMS.getValue(key);
|
||||
if (item == null || item == Items.AIR)
|
||||
throw new IllegalStateException("Unknown vanilla item: " + key.toString());
|
||||
getOrCreateBuilder(tag).add(item);
|
||||
tag(tag).add(item);
|
||||
consumer.accept(tag);
|
||||
}
|
||||
}
|
||||
@@ -160,8 +160,8 @@ public class ForgeItemTagsProvider extends ItemTagsProvider
|
||||
String itemPre = itemGroup.getName().getPath().toUpperCase(Locale.ENGLISH) + '_';
|
||||
for (DyeColor color : DyeColor.values())
|
||||
{
|
||||
ITag.INamedTag<Block> from = getForgeBlockTag(blockPre + color.getTranslationKey());
|
||||
ITag.INamedTag<Item> to = getForgeItemTag(itemPre + color.getTranslationKey());
|
||||
ITag.INamedTag<Block> from = getForgeBlockTag(blockPre + color.getName());
|
||||
ITag.INamedTag<Item> to = getForgeItemTag(itemPre + color.getName());
|
||||
copy(from, to);
|
||||
}
|
||||
copy(getForgeBlockTag(blockPre + "colorless"), getForgeItemTag(itemPre + "colorless"));
|
||||
|
||||
@@ -73,11 +73,11 @@ public class ForgeLootTableProvider extends LootTableProvider {
|
||||
}
|
||||
|
||||
private boolean findAndReplaceInLootTableBuilder(LootTable.Builder builder, Item from, ITag.INamedTag<Item> to) {
|
||||
List<LootPool> lootPools = ObfuscationReflectionHelper.getPrivateValue(LootTable.Builder.class, builder, "field_216041_a");
|
||||
List<LootPool> lootPools = ObfuscationReflectionHelper.getPrivateValue(LootTable.Builder.class, builder, "pools");
|
||||
boolean found = false;
|
||||
|
||||
if (lootPools == null) {
|
||||
throw new IllegalStateException(LootTable.Builder.class.getName() + " is missing field field_216041_a");
|
||||
throw new IllegalStateException(LootTable.Builder.class.getName() + " is missing field pools");
|
||||
}
|
||||
|
||||
for (LootPool lootPool : lootPools) {
|
||||
@@ -90,12 +90,12 @@ public class ForgeLootTableProvider extends LootTableProvider {
|
||||
}
|
||||
|
||||
private boolean findAndReplaceInLootPool(LootPool lootPool, Item from, ITag.INamedTag<Item> to) {
|
||||
List<LootEntry> lootEntries = ObfuscationReflectionHelper.getPrivateValue(LootPool.class, lootPool, "field_186453_a");
|
||||
List<ILootCondition> lootConditions = ObfuscationReflectionHelper.getPrivateValue(LootPool.class, lootPool, "field_186454_b");
|
||||
List<LootEntry> lootEntries = ObfuscationReflectionHelper.getPrivateValue(LootPool.class, lootPool, "entries");
|
||||
List<ILootCondition> lootConditions = ObfuscationReflectionHelper.getPrivateValue(LootPool.class, lootPool, "conditions");
|
||||
boolean found = false;
|
||||
|
||||
if (lootEntries == null) {
|
||||
throw new IllegalStateException(LootPool.class.getName() + " is missing field field_186453_a");
|
||||
throw new IllegalStateException(LootPool.class.getName() + " is missing field entries");
|
||||
}
|
||||
|
||||
for (LootEntry lootEntry : lootEntries) {
|
||||
@@ -107,19 +107,19 @@ public class ForgeLootTableProvider extends LootTableProvider {
|
||||
}
|
||||
|
||||
if (lootConditions == null) {
|
||||
throw new IllegalStateException(LootPool.class.getName() + " is missing field field_186454_b");
|
||||
throw new IllegalStateException(LootPool.class.getName() + " is missing field conditions");
|
||||
}
|
||||
|
||||
for (int i = 0; i < lootConditions.size(); i++) {
|
||||
ILootCondition lootCondition = lootConditions.get(i);
|
||||
if (lootCondition instanceof MatchTool && checkMatchTool((MatchTool) lootCondition, from)) {
|
||||
lootConditions.set(i, MatchTool.builder(ItemPredicate.Builder.create().tag(to)).build());
|
||||
lootConditions.set(i, MatchTool.toolMatches(ItemPredicate.Builder.item().of(to)).build());
|
||||
found = true;
|
||||
} else if (lootCondition instanceof Inverted) {
|
||||
ILootCondition invLootCondition = ObfuscationReflectionHelper.getPrivateValue(Inverted.class, (Inverted) lootCondition, "field_215981_a");
|
||||
ILootCondition invLootCondition = ObfuscationReflectionHelper.getPrivateValue(Inverted.class, (Inverted) lootCondition, "term");
|
||||
|
||||
if (invLootCondition instanceof MatchTool && checkMatchTool((MatchTool) invLootCondition, from)) {
|
||||
lootConditions.set(i, Inverted.builder(MatchTool.builder(ItemPredicate.Builder.create().tag(to))).build());
|
||||
lootConditions.set(i, Inverted.invert(MatchTool.toolMatches(ItemPredicate.Builder.item().of(to))).build());
|
||||
found = true;
|
||||
} else if (invLootCondition instanceof Alternative && findAndReplaceInAlternative((Alternative) invLootCondition, from, to)) {
|
||||
found = true;
|
||||
@@ -131,11 +131,11 @@ public class ForgeLootTableProvider extends LootTableProvider {
|
||||
}
|
||||
|
||||
private boolean findAndReplaceInParentedLootEntry(ParentedLootEntry entry, Item from, ITag.INamedTag<Item> to) {
|
||||
LootEntry[] lootEntries = ObfuscationReflectionHelper.getPrivateValue(ParentedLootEntry.class, entry, "field_216147_c");
|
||||
LootEntry[] lootEntries = ObfuscationReflectionHelper.getPrivateValue(ParentedLootEntry.class, entry, "children");
|
||||
boolean found = false;
|
||||
|
||||
if (lootEntries == null) {
|
||||
throw new IllegalStateException(ParentedLootEntry.class.getName() + " is missing field field_216147_c");
|
||||
throw new IllegalStateException(ParentedLootEntry.class.getName() + " is missing field children");
|
||||
}
|
||||
|
||||
for (LootEntry lootEntry : lootEntries) {
|
||||
@@ -148,18 +148,18 @@ public class ForgeLootTableProvider extends LootTableProvider {
|
||||
}
|
||||
|
||||
private boolean findAndReplaceInLootEntry(LootEntry entry, Item from, ITag.INamedTag<Item> to) {
|
||||
ILootCondition[] lootConditions = ObfuscationReflectionHelper.getPrivateValue(LootEntry.class, entry, "field_216144_d");
|
||||
ILootCondition[] lootConditions = ObfuscationReflectionHelper.getPrivateValue(LootEntry.class, entry, "conditions");
|
||||
boolean found = false;
|
||||
|
||||
if (lootConditions == null) {
|
||||
throw new IllegalStateException(LootEntry.class.getName() + " is missing field field_216144_d");
|
||||
throw new IllegalStateException(LootEntry.class.getName() + " is missing field conditions");
|
||||
}
|
||||
|
||||
for (int i = 0; i < lootConditions.length; i++) {
|
||||
if (lootConditions[i] instanceof Alternative && findAndReplaceInAlternative((Alternative) lootConditions[i], from, to)) {
|
||||
found = true;
|
||||
} else if (lootConditions[i] instanceof MatchTool && checkMatchTool((MatchTool) lootConditions[i], from)) {
|
||||
lootConditions[i] = MatchTool.builder(ItemPredicate.Builder.create().tag(to)).build();
|
||||
lootConditions[i] = MatchTool.toolMatches(ItemPredicate.Builder.item().of(to)).build();
|
||||
found = true;
|
||||
}
|
||||
}
|
||||
@@ -168,16 +168,16 @@ public class ForgeLootTableProvider extends LootTableProvider {
|
||||
}
|
||||
|
||||
private boolean findAndReplaceInAlternative(Alternative alternative, Item from, ITag.INamedTag<Item> to) {
|
||||
ILootCondition[] lootConditions = ObfuscationReflectionHelper.getPrivateValue(Alternative.class, alternative, "field_215962_a");
|
||||
ILootCondition[] lootConditions = ObfuscationReflectionHelper.getPrivateValue(Alternative.class, alternative, "terms");
|
||||
boolean found = false;
|
||||
|
||||
if (lootConditions == null) {
|
||||
throw new IllegalStateException(Alternative.class.getName() + " is missing field field_215962_a");
|
||||
throw new IllegalStateException(Alternative.class.getName() + " is missing field terms");
|
||||
}
|
||||
|
||||
for (int i = 0; i < lootConditions.length; i++) {
|
||||
if (lootConditions[i] instanceof MatchTool && checkMatchTool((MatchTool) lootConditions[i], from)) {
|
||||
lootConditions[i] = MatchTool.builder(ItemPredicate.Builder.create().tag(to)).build();
|
||||
lootConditions[i] = MatchTool.toolMatches(ItemPredicate.Builder.item().of(to)).build();
|
||||
found = true;
|
||||
}
|
||||
}
|
||||
@@ -186,8 +186,8 @@ public class ForgeLootTableProvider extends LootTableProvider {
|
||||
}
|
||||
|
||||
private boolean checkMatchTool(MatchTool lootCondition, Item expected) {
|
||||
ItemPredicate predicate = ObfuscationReflectionHelper.getPrivateValue(MatchTool.class, lootCondition, "field_216014_a");
|
||||
Item item = ObfuscationReflectionHelper.getPrivateValue(ItemPredicate.class, predicate, "field_192496_b");
|
||||
ItemPredicate predicate = ObfuscationReflectionHelper.getPrivateValue(MatchTool.class, lootCondition, "predicate");
|
||||
Item item = ObfuscationReflectionHelper.getPrivateValue(ItemPredicate.class, predicate, "item");
|
||||
return item != null && item.equals(expected);
|
||||
}
|
||||
}
|
||||
@@ -71,7 +71,7 @@ public class ForgeRecipeProvider extends RecipeProvider
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void registerRecipes(Consumer<IFinishedRecipe> consumer)
|
||||
protected void buildShapelessRecipes(Consumer<IFinishedRecipe> consumer)
|
||||
{
|
||||
replace(Items.STICK, Tags.Items.RODS_WOODEN);
|
||||
replace(Items.GOLD_INGOT, Tags.Items.INGOTS_GOLD);
|
||||
@@ -94,7 +94,7 @@ public class ForgeRecipeProvider extends RecipeProvider
|
||||
exclude(Blocks.COBBLESTONE_SLAB);
|
||||
exclude(Blocks.COBBLESTONE_WALL);
|
||||
|
||||
super.registerRecipes(vanilla -> {
|
||||
super.buildShapelessRecipes(vanilla -> {
|
||||
IFinishedRecipe modified = enhance(vanilla);
|
||||
if (modified != null)
|
||||
consumer.accept(modified);
|
||||
@@ -102,7 +102,7 @@ public class ForgeRecipeProvider extends RecipeProvider
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void saveRecipeAdvancement(DirectoryCache cache, JsonObject advancementJson, Path pathIn) {
|
||||
protected void saveAdvancement(DirectoryCache cache, JsonObject advancementJson, Path pathIn) {
|
||||
//NOOP - We dont replace any of the advancement things yet...
|
||||
}
|
||||
|
||||
@@ -121,7 +121,7 @@ public class ForgeRecipeProvider extends RecipeProvider
|
||||
boolean modified = false;
|
||||
for (int x = 0; x < ingredients.size(); x++)
|
||||
{
|
||||
Ingredient ing = enhance(vanilla.getID(), ingredients.get(x));
|
||||
Ingredient ing = enhance(vanilla.getId(), ingredients.get(x));
|
||||
if (ing != null)
|
||||
{
|
||||
ingredients.set(x, ing);
|
||||
@@ -137,7 +137,7 @@ public class ForgeRecipeProvider extends RecipeProvider
|
||||
boolean modified = false;
|
||||
for (Character x : ingredients.keySet())
|
||||
{
|
||||
Ingredient ing = enhance(vanilla.getID(), ingredients.get(x));
|
||||
Ingredient ing = enhance(vanilla.getId(), ingredients.get(x));
|
||||
if (ing != null)
|
||||
{
|
||||
ingredients.put(x, ing);
|
||||
@@ -159,7 +159,7 @@ public class ForgeRecipeProvider extends RecipeProvider
|
||||
{
|
||||
if (entry instanceof SingleItemList)
|
||||
{
|
||||
ItemStack stack = entry.getStacks().stream().findFirst().orElse(ItemStack.EMPTY);
|
||||
ItemStack stack = entry.getItems().stream().findFirst().orElse(ItemStack.EMPTY);
|
||||
ITag<Item> replacement = replacements.get(stack.getItem());
|
||||
if (replacement != null)
|
||||
{
|
||||
@@ -172,7 +172,7 @@ public class ForgeRecipeProvider extends RecipeProvider
|
||||
else
|
||||
items.add(entry);
|
||||
}
|
||||
return modified ? Ingredient.fromItemListStream(items.stream()) : null;
|
||||
return modified ? Ingredient.fromValues(items.stream()) : null;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
|
||||
@@ -68,7 +68,7 @@ public abstract class ForgeRegistryTagsProvider<T extends IForgeRegistryEntry<T>
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Path makePath(ResourceLocation id)
|
||||
protected Path getPath(ResourceLocation id)
|
||||
{
|
||||
return generator.getOutputFolder().resolve("data/" + id.getNamespace() + "/tags/" + folder + "/" + id.getPath() + ".json");
|
||||
}
|
||||
|
||||
@@ -73,7 +73,7 @@ public abstract class GlobalLootModifierProvider implements IDataProvider
|
||||
protected abstract void start();
|
||||
|
||||
@Override
|
||||
public void act(DirectoryCache cache) throws IOException
|
||||
public void run(DirectoryCache cache) throws IOException
|
||||
{
|
||||
start();
|
||||
|
||||
|
||||
@@ -61,7 +61,7 @@ public abstract class LanguageProvider implements IDataProvider {
|
||||
protected abstract void addTranslations();
|
||||
|
||||
@Override
|
||||
public void act(DirectoryCache cache) throws IOException {
|
||||
public void run(DirectoryCache cache) throws IOException {
|
||||
addTranslations();
|
||||
if (!data.isEmpty())
|
||||
save(cache, data, this.gen.getOutputFolder().resolve("assets/" + modid + "/lang/" + locale + ".json"));
|
||||
@@ -75,8 +75,8 @@ public abstract class LanguageProvider implements IDataProvider {
|
||||
private void save(DirectoryCache cache, Object object, Path target) throws IOException {
|
||||
String data = GSON.toJson(object);
|
||||
data = JavaUnicodeEscaper.outsideOf(0, 0x7f).translate(data); // Escape unicode after the fact so that it's not double escaped by GSON
|
||||
String hash = IDataProvider.HASH_FUNCTION.hashUnencodedChars(data).toString();
|
||||
if (!Objects.equals(cache.getPreviousHash(target), hash) || !Files.exists(target)) {
|
||||
String hash = IDataProvider.SHA1.hashUnencodedChars(data).toString();
|
||||
if (!Objects.equals(cache.getHash(target), hash) || !Files.exists(target)) {
|
||||
Files.createDirectories(target.getParent());
|
||||
|
||||
try (BufferedWriter bufferedwriter = Files.newBufferedWriter(target)) {
|
||||
@@ -84,7 +84,7 @@ public abstract class LanguageProvider implements IDataProvider {
|
||||
}
|
||||
}
|
||||
|
||||
cache.recordHash(target, hash);
|
||||
cache.putNew(target, hash);
|
||||
}
|
||||
|
||||
public void addBlock(Supplier<? extends Block> key, String name) {
|
||||
@@ -92,7 +92,7 @@ public abstract class LanguageProvider implements IDataProvider {
|
||||
}
|
||||
|
||||
public void add(Block key, String name) {
|
||||
add(key.getTranslationKey(), name);
|
||||
add(key.getDescriptionId(), name);
|
||||
}
|
||||
|
||||
public void addItem(Supplier<? extends Item> key, String name) {
|
||||
@@ -100,7 +100,7 @@ public abstract class LanguageProvider implements IDataProvider {
|
||||
}
|
||||
|
||||
public void add(Item key, String name) {
|
||||
add(key.getTranslationKey(), name);
|
||||
add(key.getDescriptionId(), name);
|
||||
}
|
||||
|
||||
public void addItemStack(Supplier<ItemStack> key, String name) {
|
||||
@@ -108,7 +108,7 @@ public abstract class LanguageProvider implements IDataProvider {
|
||||
}
|
||||
|
||||
public void add(ItemStack key, String name) {
|
||||
add(key.getTranslationKey(), name);
|
||||
add(key.getDescriptionId(), name);
|
||||
}
|
||||
|
||||
public void addEnchantment(Supplier<? extends Enchantment> key, String name) {
|
||||
@@ -116,7 +116,7 @@ public abstract class LanguageProvider implements IDataProvider {
|
||||
}
|
||||
|
||||
public void add(Enchantment key, String name) {
|
||||
add(key.getName(), name);
|
||||
add(key.getDescriptionId(), name);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -134,7 +134,7 @@ public abstract class LanguageProvider implements IDataProvider {
|
||||
}
|
||||
|
||||
public void add(Effect key, String name) {
|
||||
add(key.getName(), name);
|
||||
add(key.getDescriptionId(), name);
|
||||
}
|
||||
|
||||
public void addEntityType(Supplier<? extends EntityType<?>> key, String name) {
|
||||
@@ -142,7 +142,7 @@ public abstract class LanguageProvider implements IDataProvider {
|
||||
}
|
||||
|
||||
public void add(EntityType<?> key, String name) {
|
||||
add(key.getTranslationKey(), name);
|
||||
add(key.getDescriptionId(), name);
|
||||
}
|
||||
|
||||
public void add(String key, String value) {
|
||||
|
||||
@@ -86,7 +86,7 @@ public interface IForgeBlock
|
||||
*/
|
||||
default float getSlipperiness(BlockState state, IWorldReader world, BlockPos pos, @Nullable Entity entity)
|
||||
{
|
||||
return getBlock().getSlipperiness();
|
||||
return getBlock().getFriction();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -99,7 +99,7 @@ public interface IForgeBlock
|
||||
*/
|
||||
default int getLightValue(BlockState state, IBlockReader world, BlockPos pos)
|
||||
{
|
||||
return state.getLightValue();
|
||||
return state.getLightEmission();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -113,7 +113,7 @@ public interface IForgeBlock
|
||||
*/
|
||||
default boolean isLadder(BlockState state, IWorldReader world, BlockPos pos, LivingEntity entity)
|
||||
{
|
||||
return state.getBlock().isIn(BlockTags.CLIMBABLE);
|
||||
return state.getBlock().is(BlockTags.CLIMBABLE);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -157,7 +157,7 @@ public interface IForgeBlock
|
||||
default TileEntity createTileEntity(BlockState state, IBlockReader world)
|
||||
{
|
||||
if (getBlock() instanceof ITileEntityProvider)
|
||||
return ((ITileEntityProvider)getBlock()).createNewTileEntity(world);
|
||||
return ((ITileEntityProvider)getBlock()).newBlockEntity(world);
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -196,8 +196,8 @@ public interface IForgeBlock
|
||||
*/
|
||||
default boolean removedByPlayer(BlockState state, World world, BlockPos pos, PlayerEntity player, boolean willHarvest, FluidState fluid)
|
||||
{
|
||||
getBlock().onBlockHarvested(world, pos, state, player);
|
||||
return world.setBlockState(pos, fluid.getBlockState(), world.isRemote ? 11 : 3);
|
||||
getBlock().playerWillDestroy(world, pos, state, player);
|
||||
return world.setBlock(pos, fluid.createLegacyBlock(), world.isClientSide ? 11 : 3);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -228,7 +228,7 @@ public interface IForgeBlock
|
||||
*/
|
||||
default boolean canCreatureSpawn(BlockState state, IBlockReader world, BlockPos pos, EntitySpawnPlacementRegistry.PlacementType type, @Nullable EntityType<?> entityType)
|
||||
{
|
||||
return state.canEntitySpawn(world, pos, entityType);
|
||||
return state.isValidSpawn(world, pos, entityType);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -246,7 +246,7 @@ public interface IForgeBlock
|
||||
{
|
||||
if (world instanceof World)
|
||||
{
|
||||
return BedBlock.func_242652_a(entityType, world, pos, orientation);
|
||||
return BedBlock.findStandUpPosition(entityType, world, pos, orientation);
|
||||
}
|
||||
|
||||
return Optional.empty();
|
||||
@@ -263,7 +263,7 @@ public interface IForgeBlock
|
||||
*/
|
||||
default void setBedOccupied(BlockState state, World world, BlockPos pos, LivingEntity sleeper, boolean occupied)
|
||||
{
|
||||
world.setBlockState(pos, state.with(BedBlock.OCCUPIED, occupied), 3);
|
||||
world.setBlock(pos, state.setValue(BedBlock.OCCUPIED, occupied), 3);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -277,7 +277,7 @@ public interface IForgeBlock
|
||||
*/
|
||||
default Direction getBedDirection(BlockState state, IWorldReader world, BlockPos pos)
|
||||
{
|
||||
return state.get(HorizontalBlock.HORIZONTAL_FACING);
|
||||
return state.getValue(HorizontalBlock.FACING);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -306,7 +306,7 @@ public interface IForgeBlock
|
||||
*/
|
||||
default boolean canBeReplacedByLeaves(BlockState state, IWorldReader world, BlockPos pos)
|
||||
{
|
||||
return isAir(state, world, pos) || state.isIn(BlockTags.LEAVES);
|
||||
return isAir(state, world, pos) || state.is(BlockTags.LEAVES);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -319,8 +319,8 @@ public interface IForgeBlock
|
||||
*/
|
||||
default boolean canBeReplacedByLogs(BlockState state, IWorldReader world, BlockPos pos)
|
||||
{
|
||||
return (isAir(state, world, pos) || state.isIn(BlockTags.LEAVES)) || this == Blocks.GRASS_BLOCK || state.isIn(Tags.Blocks.DIRT)
|
||||
|| getBlock().isIn(BlockTags.LOGS) || getBlock().isIn(BlockTags.SAPLINGS) || this == Blocks.VINE;
|
||||
return (isAir(state, world, pos) || state.is(BlockTags.LEAVES)) || this == Blocks.GRASS_BLOCK || state.is(Tags.Blocks.DIRT)
|
||||
|| getBlock().is(BlockTags.LOGS) || getBlock().is(BlockTags.SAPLINGS) || this == Blocks.VINE;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -348,7 +348,7 @@ public interface IForgeBlock
|
||||
*/
|
||||
default boolean canConnectRedstone(BlockState state, IBlockReader world, BlockPos pos, @Nullable Direction side)
|
||||
{
|
||||
return state.canProvidePower() && side != null;
|
||||
return state.isSignalSource() && side != null;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -360,7 +360,7 @@ public interface IForgeBlock
|
||||
*/
|
||||
default ItemStack getPickBlock(BlockState state, RayTraceResult target, IBlockReader world, BlockPos pos, PlayerEntity player)
|
||||
{
|
||||
return this.getBlock().getItem(world, pos, state);
|
||||
return this.getBlock().getCloneItemStack(world, pos, state);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -469,8 +469,8 @@ public interface IForgeBlock
|
||||
@Deprecated//TODO - 1.17: Remove (unused)
|
||||
default void onPlantGrow(BlockState state, IWorld world, BlockPos pos, BlockPos source)
|
||||
{
|
||||
if (state.isIn(Tags.Blocks.DIRT))
|
||||
world.setBlockState(pos, Blocks.DIRT.getDefaultState(), 2);
|
||||
if (state.is(Tags.Blocks.DIRT))
|
||||
world.setBlock(pos, Blocks.DIRT.defaultBlockState(), 2);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -484,8 +484,8 @@ public interface IForgeBlock
|
||||
*/
|
||||
default boolean isFertile(BlockState state, IBlockReader world, BlockPos pos)
|
||||
{
|
||||
if (state.isIn(Blocks.FARMLAND))
|
||||
return state.get(FarmlandBlock.MOISTURE) > 0;
|
||||
if (state.is(Blocks.FARMLAND))
|
||||
return state.getValue(FarmlandBlock.MOISTURE) > 0;
|
||||
|
||||
return false;
|
||||
}
|
||||
@@ -516,7 +516,7 @@ public interface IForgeBlock
|
||||
*/
|
||||
default boolean isPortalFrame(BlockState state, IBlockReader world, BlockPos pos)
|
||||
{
|
||||
return state.isIn(Blocks.OBSIDIAN);
|
||||
return state.is(Blocks.OBSIDIAN);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -546,7 +546,7 @@ public interface IForgeBlock
|
||||
*/
|
||||
default float getEnchantPowerBonus(BlockState state, IWorldReader world, BlockPos pos)
|
||||
{
|
||||
return state.isIn(Blocks.BOOKSHELF) ? 1: 0;
|
||||
return state.is(Blocks.BOOKSHELF) ? 1: 0;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -578,7 +578,7 @@ public interface IForgeBlock
|
||||
*/
|
||||
default boolean shouldCheckWeakPower(BlockState state, IWorldReader world, BlockPos pos, Direction side)
|
||||
{
|
||||
return state.isNormalCube(world, pos);
|
||||
return state.isRedstoneConductor(world, pos);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -644,7 +644,7 @@ public interface IForgeBlock
|
||||
default float[] getBeaconColorMultiplier(BlockState state, IWorldReader world, BlockPos pos, BlockPos beaconPos)
|
||||
{
|
||||
if (getBlock() instanceof IBeaconBeamColorProvider)
|
||||
return ((IBeaconBeamColorProvider)getBlock()).getColor().getColorComponentValues();
|
||||
return ((IBeaconBeamColorProvider)getBlock()).getColor().getTextureDiffuseColors();
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -669,9 +669,9 @@ public interface IForgeBlock
|
||||
if (entity instanceof LivingEntity)
|
||||
{
|
||||
LivingEntity ent = (LivingEntity)entity;
|
||||
f12 = (float) EnchantmentHelper.getRespirationModifier(ent) * 0.2F;
|
||||
f12 = (float) EnchantmentHelper.getRespiration(ent) * 0.2F;
|
||||
|
||||
if (ent.isPotionActive(Effects.WATER_BREATHING))
|
||||
if (ent.hasEffect(Effects.WATER_BREATHING))
|
||||
{
|
||||
f12 = f12 * 0.3F + 0.6F;
|
||||
}
|
||||
@@ -755,7 +755,7 @@ public interface IForgeBlock
|
||||
*/
|
||||
default int getFlammability(BlockState state, IBlockReader world, BlockPos pos, Direction face)
|
||||
{
|
||||
return ((FireBlock)Blocks.FIRE).getFlammability(state);
|
||||
return ((FireBlock)Blocks.FIRE).getBurnOdd(state);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -796,7 +796,7 @@ public interface IForgeBlock
|
||||
*/
|
||||
default int getFireSpreadSpeed(BlockState state, IBlockReader world, BlockPos pos, Direction face)
|
||||
{
|
||||
return ((FireBlock)Blocks.FIRE).getFireSpreadSpeed(state);
|
||||
return ((FireBlock)Blocks.FIRE).getFlameOdds(state);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -812,7 +812,7 @@ public interface IForgeBlock
|
||||
*/
|
||||
default boolean isFireSource(BlockState state, IWorldReader world, BlockPos pos, Direction side)
|
||||
{
|
||||
return state.isIn(world.getDimensionType().isInfiniBurn());
|
||||
return state.is(world.dimensionType().infiniburn());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -832,7 +832,7 @@ public interface IForgeBlock
|
||||
else if ((entity instanceof WitherEntity) ||
|
||||
(entity instanceof WitherSkullEntity))
|
||||
{
|
||||
return state.isAir(world, pos) || WitherEntity.canDestroyBlock(state);
|
||||
return state.isAir(world, pos) || WitherEntity.canDestroy(state);
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -843,7 +843,7 @@ public interface IForgeBlock
|
||||
*/
|
||||
default boolean canDropFromExplosion(BlockState state, IBlockReader world, BlockPos pos, Explosion explosion)
|
||||
{
|
||||
return state.getBlock().canDropFromExplosion(explosion);
|
||||
return state.getBlock().dropFromExplosion(explosion);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -863,8 +863,8 @@ public interface IForgeBlock
|
||||
*/
|
||||
default void onBlockExploded(BlockState state, World world, BlockPos pos, Explosion explosion)
|
||||
{
|
||||
world.setBlockState(pos, Blocks.AIR.getDefaultState(), 3);
|
||||
getBlock().onExplosionDestroy(world, pos, explosion);
|
||||
world.setBlock(pos, Blocks.AIR.defaultBlockState(), 3);
|
||||
getBlock().wasExploded(world, pos, explosion);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -873,7 +873,7 @@ public interface IForgeBlock
|
||||
*/
|
||||
default boolean collisionExtendsVertically(BlockState state, IBlockReader world, BlockPos pos, Entity collidingEntity)
|
||||
{
|
||||
return getBlock().isIn(BlockTags.FENCES) || getBlock().isIn(BlockTags.WALLS) || getBlock() instanceof FenceGateBlock;
|
||||
return getBlock().is(BlockTags.FENCES) || getBlock().is(BlockTags.WALLS) || getBlock() instanceof FenceGateBlock;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -921,6 +921,6 @@ public interface IForgeBlock
|
||||
*/
|
||||
default boolean isScaffolding(BlockState state, IWorldReader world, BlockPos pos, LivingEntity entity)
|
||||
{
|
||||
return state.isIn(Blocks.SCAFFOLDING);
|
||||
return state.is(Blocks.SCAFFOLDING);
|
||||
}
|
||||
}
|
||||
@@ -806,6 +806,6 @@ public interface IForgeBlockState
|
||||
*/
|
||||
default boolean isScaffolding(LivingEntity entity)
|
||||
{
|
||||
return getBlockState().getBlock().isScaffolding(getBlockState(), entity.world, entity.getPosition(), entity);
|
||||
return getBlockState().getBlock().isScaffolding(getBlockState(), entity.level, entity.blockPosition(), entity);
|
||||
}
|
||||
}
|
||||
@@ -106,6 +106,6 @@ public interface IForgeEffect {
|
||||
* @return a value used to sort {@code PotionEffect}s in GUIs
|
||||
*/
|
||||
default int getGuiSortColor(EffectInstance potionEffect) {
|
||||
return getEffect().getLiquidColor();
|
||||
return getEffect().getColor();
|
||||
}
|
||||
}
|
||||
@@ -43,7 +43,7 @@ public interface IForgeEffectInstance {
|
||||
* @return true to display it (default), false to hide it.
|
||||
*/
|
||||
default boolean shouldRender() {
|
||||
return getEffectInstance().getPotion().shouldRender(getEffectInstance());
|
||||
return getEffectInstance().getEffect().shouldRender(getEffectInstance());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -51,7 +51,7 @@ public interface IForgeEffectInstance {
|
||||
* @return true to draw the standard text
|
||||
*/
|
||||
default boolean shouldRenderInvText() {
|
||||
return getEffectInstance().getPotion().shouldRenderInvText(getEffectInstance());
|
||||
return getEffectInstance().getEffect().shouldRenderInvText(getEffectInstance());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -59,7 +59,7 @@ public interface IForgeEffectInstance {
|
||||
* @return true to display it (default), false to hide it.
|
||||
*/
|
||||
default boolean shouldRenderHUD() {
|
||||
return getEffectInstance().getPotion().shouldRenderHUD(getEffectInstance());
|
||||
return getEffectInstance().getEffect().shouldRenderHUD(getEffectInstance());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -74,7 +74,7 @@ public interface IForgeEffectInstance {
|
||||
*/
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
default void renderInventoryEffect(DisplayEffectsScreen<?> gui, MatrixStack mStack, int x, int y, float z) {
|
||||
getEffectInstance().getPotion().renderInventoryEffect(getEffectInstance(), gui, mStack, x, y, z);
|
||||
getEffectInstance().getEffect().renderInventoryEffect(getEffectInstance(), gui, mStack, x, y, z);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -90,7 +90,7 @@ public interface IForgeEffectInstance {
|
||||
*/
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
default void renderHUDEffect(AbstractGui gui, MatrixStack mStack, int x, int y, float z, float alpha) {
|
||||
getEffectInstance().getPotion().renderHUDEffect(getEffectInstance(), gui, mStack, x, y, z, alpha);
|
||||
getEffectInstance().getEffect().renderHUDEffect(getEffectInstance(), gui, mStack, x, y, z, alpha);
|
||||
}
|
||||
|
||||
/***
|
||||
@@ -107,7 +107,7 @@ public interface IForgeEffectInstance {
|
||||
* @return true if the given ItemStack is in the list of curative items for this PotionEffect, false otherwise
|
||||
*/
|
||||
default boolean isCurativeItem(ItemStack stack) {
|
||||
return this.getCurativeItems().stream().anyMatch(e -> e.isItemEqual(stack));
|
||||
return this.getCurativeItems().stream().anyMatch(e -> e.sameItem(stack));
|
||||
}
|
||||
|
||||
/***
|
||||
@@ -127,7 +127,7 @@ public interface IForgeEffectInstance {
|
||||
|
||||
default void writeCurativeItems(CompoundNBT nbt) {
|
||||
ListNBT list = new ListNBT();
|
||||
getCurativeItems().forEach(s -> list.add(s.write(new CompoundNBT())));
|
||||
getCurativeItems().forEach(s -> list.add(s.save(new CompoundNBT())));
|
||||
nbt.put("CurativeItems", list);
|
||||
}
|
||||
}
|
||||
@@ -49,18 +49,18 @@ public interface IForgeEntity extends ICapabilitySerializable<CompoundNBT>
|
||||
|
||||
default void deserializeNBT(CompoundNBT nbt)
|
||||
{
|
||||
getEntity().read(nbt);
|
||||
getEntity().load(nbt);
|
||||
}
|
||||
|
||||
default CompoundNBT serializeNBT()
|
||||
{
|
||||
CompoundNBT ret = new CompoundNBT();
|
||||
String id = getEntity().getEntityString();
|
||||
String id = getEntity().getEncodeId();
|
||||
if (id != null)
|
||||
{
|
||||
ret.putString("id", getEntity().getEntityString());
|
||||
ret.putString("id", getEntity().getEncodeId());
|
||||
}
|
||||
return getEntity().writeWithoutTypeId(ret);
|
||||
return getEntity().saveWithoutId(ret);
|
||||
}
|
||||
|
||||
boolean canUpdate();
|
||||
@@ -101,7 +101,7 @@ public interface IForgeEntity extends ICapabilitySerializable<CompoundNBT>
|
||||
return new ItemStack(Items.LEAD);
|
||||
else if (this instanceof ItemFrameEntity)
|
||||
{
|
||||
ItemStack held = ((ItemFrameEntity)this).getDisplayedItem();
|
||||
ItemStack held = ((ItemFrameEntity)this).getItem();
|
||||
if (held.isEmpty())
|
||||
return new ItemStack(Items.ITEM_FRAME);
|
||||
else
|
||||
@@ -110,14 +110,14 @@ public interface IForgeEntity extends ICapabilitySerializable<CompoundNBT>
|
||||
else if (this instanceof AbstractMinecartEntity)
|
||||
return ((AbstractMinecartEntity)this).getCartItem();
|
||||
else if (this instanceof BoatEntity)
|
||||
return new ItemStack(((BoatEntity)this).getItemBoat());
|
||||
return new ItemStack(((BoatEntity)this).getDropItem());
|
||||
else if (this instanceof ArmorStandEntity)
|
||||
return new ItemStack(Items.ARMOR_STAND);
|
||||
else if (this instanceof EnderCrystalEntity)
|
||||
return new ItemStack(Items.END_CRYSTAL);
|
||||
else
|
||||
{
|
||||
SpawnEggItem egg = SpawnEggItem.getEgg(getEntity().getType());
|
||||
SpawnEggItem egg = SpawnEggItem.byId(getEntity().getType());
|
||||
if (egg != null) return new ItemStack(egg);
|
||||
}
|
||||
return ItemStack.EMPTY;
|
||||
@@ -142,7 +142,7 @@ public interface IForgeEntity extends ICapabilitySerializable<CompoundNBT>
|
||||
*/
|
||||
default boolean canBeRiddenInWater(Entity rider)
|
||||
{
|
||||
return getEntity().canBeRiddenInWater();
|
||||
return getEntity().rideableUnderWater();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -161,7 +161,7 @@ public interface IForgeEntity extends ICapabilitySerializable<CompoundNBT>
|
||||
*/
|
||||
default EntityClassification getClassification(boolean forSpawnCount)
|
||||
{
|
||||
return getEntity().getType().getClassification();
|
||||
return getEntity().getType().getCategory();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -52,11 +52,11 @@ public interface IForgeEntityMinecart
|
||||
*/
|
||||
default BlockPos getCurrentRailPosition()
|
||||
{
|
||||
int x = MathHelper.floor(getMinecart().getPosX());
|
||||
int y = MathHelper.floor(getMinecart().getPosY());
|
||||
int z = MathHelper.floor(getMinecart().getPosZ());
|
||||
int x = MathHelper.floor(getMinecart().getX());
|
||||
int y = MathHelper.floor(getMinecart().getY());
|
||||
int z = MathHelper.floor(getMinecart().getZ());
|
||||
BlockPos pos = new BlockPos(x, y, z);
|
||||
if (getMinecart().world.getBlockState(pos.down()).isIn(BlockTags.RAILS)) pos = pos.down();
|
||||
if (getMinecart().level.getBlockState(pos.below()).is(BlockTags.RAILS)) pos = pos.below();
|
||||
return pos;
|
||||
}
|
||||
|
||||
|
||||
@@ -56,7 +56,7 @@ public interface IForgeFluid
|
||||
*/
|
||||
default boolean isEntityInside(FluidState state, IWorldReader world, BlockPos pos, Entity entity, double yToTest, Tag<Fluid> tag, boolean testingHead)
|
||||
{
|
||||
return state.isTagged(tag) && yToTest < (double)(pos.getY() + state.getActualHeight(world, pos) + 0.11111111F);
|
||||
return state.is(tag) && yToTest < (double)(pos.getY() + state.getHeight(world, pos) + 0.11111111F);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -52,7 +52,7 @@ public interface IForgeFluidState
|
||||
default boolean isEntityInside(IWorldReader world, BlockPos pos, Entity entity, double yToTest, Tag<Fluid> tag, boolean testingHead)
|
||||
{
|
||||
// return ifluidstate.isTagged(p_213290_1_) && d0 < (double)((float)blockpos.getY() + ifluidstate.getActualHeight(this.world, blockpos) + 0.11111111F);
|
||||
return getFluidState().getFluid().isEntityInside(getFluidState(), world, pos, entity, yToTest, tag, testingHead);
|
||||
return getFluidState().getType().isEntityInside(getFluidState(), world, pos, entity, yToTest, tag, testingHead);
|
||||
}
|
||||
|
||||
|
||||
@@ -67,7 +67,7 @@ public interface IForgeFluidState
|
||||
*/
|
||||
default float getExplosionResistance(IBlockReader world, BlockPos pos, Explosion explosion)
|
||||
{
|
||||
return getFluidState().getFluid().getExplosionResistance(getFluidState(), world, pos, explosion);
|
||||
return getFluidState().getType().getExplosionResistance(getFluidState(), world, pos, explosion);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -74,7 +74,7 @@ public interface IForgeItem
|
||||
@SuppressWarnings("deprecation")
|
||||
default Multimap<Attribute, AttributeModifier> getAttributeModifiers(EquipmentSlotType slot, ItemStack stack)
|
||||
{
|
||||
return getItem().getAttributeModifiers(slot);
|
||||
return getItem().getDefaultAttributeModifiers(slot);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -121,7 +121,7 @@ public interface IForgeItem
|
||||
*/
|
||||
default boolean isPiglinCurrency(ItemStack stack)
|
||||
{
|
||||
return stack.getItem() == PiglinTasks.field_234444_a_;
|
||||
return stack.getItem() == PiglinTasks.BARTERING_ITEM;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -134,7 +134,7 @@ public interface IForgeItem
|
||||
*/
|
||||
default boolean makesPiglinsNeutral(ItemStack stack, LivingEntity wearer)
|
||||
{
|
||||
return stack.getItem() instanceof ArmorItem && ((ArmorItem) stack.getItem()).getArmorMaterial() == ArmorMaterial.GOLD;
|
||||
return stack.getItem() instanceof ArmorItem && ((ArmorItem) stack.getItem()).getMaterial() == ArmorMaterial.GOLD;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -244,7 +244,7 @@ public interface IForgeItem
|
||||
{
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
return new ItemStack(getItem().getContainerItem());
|
||||
return new ItemStack(getItem().getCraftingRemainingItem());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -256,7 +256,7 @@ public interface IForgeItem
|
||||
@SuppressWarnings("deprecation")
|
||||
default boolean hasContainerItem(ItemStack stack)
|
||||
{
|
||||
return getItem().hasContainerItem();
|
||||
return getItem().hasCraftingRemainingItem();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -326,7 +326,7 @@ public interface IForgeItem
|
||||
*/
|
||||
default java.util.Collection<ItemGroup> getCreativeTabs()
|
||||
{
|
||||
return java.util.Collections.singletonList(getItem().getGroup());
|
||||
return java.util.Collections.singletonList(getItem().getItemCategory());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -375,7 +375,7 @@ public interface IForgeItem
|
||||
*/
|
||||
default boolean canEquip(ItemStack stack, EquipmentSlotType armorType, Entity entity)
|
||||
{
|
||||
return MobEntity.getSlotForItemStack(stack) == armorType;
|
||||
return MobEntity.getEquipmentSlotForItem(stack) == armorType;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -515,7 +515,7 @@ public interface IForgeItem
|
||||
*/
|
||||
default double getDurabilityForDisplay(ItemStack stack)
|
||||
{
|
||||
return (double) stack.getDamage() / (double) stack.getMaxDamage();
|
||||
return (double) stack.getDamageValue() / (double) stack.getMaxDamage();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -528,7 +528,7 @@ public interface IForgeItem
|
||||
*/
|
||||
default int getRGBDurabilityForDisplay(ItemStack stack)
|
||||
{
|
||||
return MathHelper.hsvToRGB(Math.max(0.0F, (float) (1.0F - getDurabilityForDisplay(stack))) / 3.0F, 1.0F, 1.0F);
|
||||
return MathHelper.hsvToRgb(Math.max(0.0F, (float) (1.0F - getDurabilityForDisplay(stack))) / 3.0F, 1.0F, 1.0F);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -553,7 +553,7 @@ public interface IForgeItem
|
||||
*/
|
||||
default boolean isDamaged(ItemStack stack)
|
||||
{
|
||||
return stack.getDamage() > 0;
|
||||
return stack.getDamageValue() > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -577,7 +577,7 @@ public interface IForgeItem
|
||||
*/
|
||||
default boolean canHarvestBlock(ItemStack stack, BlockState state)
|
||||
{
|
||||
return getItem().canHarvestBlock(state);
|
||||
return getItem().isCorrectToolForDrops(state);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -615,7 +615,7 @@ public interface IForgeItem
|
||||
*/
|
||||
default int getItemEnchantability(ItemStack stack)
|
||||
{
|
||||
return getItem().getItemEnchantability();
|
||||
return getItem().getEnchantmentValue();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -633,7 +633,7 @@ public interface IForgeItem
|
||||
*/
|
||||
default boolean canApplyAtEnchantingTable(ItemStack stack, net.minecraft.enchantment.Enchantment enchantment)
|
||||
{
|
||||
return enchantment.type.canEnchantItem(stack.getItem());
|
||||
return enchantment.category.canEnchant(stack.getItem());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -662,8 +662,8 @@ public interface IForgeItem
|
||||
*/
|
||||
default boolean shouldCauseBlockBreakReset(ItemStack oldStack, ItemStack newStack)
|
||||
{
|
||||
return !(newStack.getItem() == oldStack.getItem() && ItemStack.areItemStackTagsEqual(newStack, oldStack)
|
||||
&& (newStack.isDamageable() || newStack.getDamage() == oldStack.getDamage()));
|
||||
return !(newStack.getItem() == oldStack.getItem() && ItemStack.tagMatches(newStack, oldStack)
|
||||
&& (newStack.isDamageableItem() || newStack.getDamageValue() == oldStack.getDamageValue()));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -677,7 +677,7 @@ public interface IForgeItem
|
||||
*/
|
||||
default boolean canContinueUsing(ItemStack oldStack, ItemStack newStack)
|
||||
{
|
||||
return ItemStack.areItemsEqualIgnoreDurability(oldStack, newStack);
|
||||
return ItemStack.isSameIgnoreDurability(oldStack, newStack);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -854,6 +854,6 @@ public interface IForgeItem
|
||||
*/
|
||||
default boolean isDamageable(ItemStack stack)
|
||||
{
|
||||
return this.getItem().isDamageable();
|
||||
return this.getItem().canBeDepleted();
|
||||
}
|
||||
}
|
||||
@@ -109,15 +109,15 @@ public interface IForgeItemStack extends ICapabilitySerializable<CompoundNBT>
|
||||
default ActionResultType onItemUseFirst(ItemUseContext context)
|
||||
{
|
||||
PlayerEntity entityplayer = context.getPlayer();
|
||||
BlockPos blockpos = context.getPos();
|
||||
CachedBlockInfo blockworldstate = new CachedBlockInfo(context.getWorld(), blockpos, false);
|
||||
if (entityplayer != null && !entityplayer.abilities.allowEdit && !getStack().canPlaceOn(context.getWorld().getTags(), blockworldstate)) {
|
||||
BlockPos blockpos = context.getClickedPos();
|
||||
CachedBlockInfo blockworldstate = new CachedBlockInfo(context.getLevel(), blockpos, false);
|
||||
if (entityplayer != null && !entityplayer.abilities.mayBuild && !getStack().hasAdventureModePlaceTagForBlock(context.getLevel().getTagManager(), blockworldstate)) {
|
||||
return ActionResultType.PASS;
|
||||
} else {
|
||||
Item item = getStack().getItem();
|
||||
ActionResultType enumactionresult = item.onItemUseFirst(getStack(), context);
|
||||
if (entityplayer != null && enumactionresult == ActionResultType.SUCCESS) {
|
||||
entityplayer.addStat(Stats.ITEM_USED.get(item));
|
||||
entityplayer.awardStat(Stats.ITEM_USED.get(item));
|
||||
}
|
||||
|
||||
return enumactionresult;
|
||||
@@ -127,7 +127,7 @@ public interface IForgeItemStack extends ICapabilitySerializable<CompoundNBT>
|
||||
default CompoundNBT serializeNBT()
|
||||
{
|
||||
CompoundNBT ret = new CompoundNBT();
|
||||
getStack().write(ret);
|
||||
getStack().save(ret);
|
||||
return ret;
|
||||
}
|
||||
/**
|
||||
@@ -422,7 +422,7 @@ public interface IForgeItemStack extends ICapabilitySerializable<CompoundNBT>
|
||||
return other.isEmpty();
|
||||
else
|
||||
return !other.isEmpty() && getStack().getCount() == other.getCount() && getStack().getItem() == other.getItem() &&
|
||||
(limitTags ? getStack().areShareTagsEqual(other) : ItemStack.areItemStackTagsEqual(getStack(), other));
|
||||
(limitTags ? getStack().areShareTagsEqual(other) : ItemStack.tagMatches(getStack(), other));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -60,7 +60,7 @@ public interface IForgeStructure
|
||||
default boolean getDefaultRestrictsSpawnsToInside()
|
||||
{
|
||||
//The Pillager Outpost and Ocean Monument check the full structure by default instead of limiting themselves to being within the structure's bounds
|
||||
return getStructure() != Structure.PILLAGER_OUTPOST && getStructure() != Structure.MONUMENT;
|
||||
return getStructure() != Structure.PILLAGER_OUTPOST && getStructure() != Structure.OCEAN_MONUMENT;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -44,7 +44,7 @@ public interface IForgeTagBuilder<T>
|
||||
default TagsProvider.Builder<T> add(RegistryKey<T>... keys) {
|
||||
TagsProvider.Builder<T> builder = getBuilder();
|
||||
for (RegistryKey<T> key : keys) {
|
||||
builder.getInternalBuilder().addItemEntry(key.getLocation(), getBuilder().getModID());
|
||||
builder.getInternalBuilder().addElement(key.location(), getBuilder().getModID());
|
||||
}
|
||||
return builder;
|
||||
}
|
||||
|
||||
@@ -51,14 +51,14 @@ public interface IForgeTileEntity extends ICapabilitySerializable<CompoundNBT>
|
||||
// @Override TODO re-evaluate
|
||||
default void deserializeNBT(BlockState state, CompoundNBT nbt)
|
||||
{
|
||||
getTileEntity().read(state, nbt);
|
||||
getTileEntity().load(state, nbt);
|
||||
}
|
||||
|
||||
@Override
|
||||
default CompoundNBT serializeNBT()
|
||||
{
|
||||
CompoundNBT ret = new CompoundNBT();
|
||||
getTileEntity().write(ret);
|
||||
getTileEntity().save(ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -82,7 +82,7 @@ public interface IForgeTileEntity extends ICapabilitySerializable<CompoundNBT>
|
||||
*/
|
||||
default void handleUpdateTag(BlockState state, CompoundNBT tag)
|
||||
{
|
||||
getTileEntity().read(state, tag);
|
||||
getTileEntity().load(state, tag);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -122,14 +122,14 @@ public interface IForgeTileEntity extends ICapabilitySerializable<CompoundNBT>
|
||||
AxisAlignedBB bb = INFINITE_EXTENT_AABB;
|
||||
BlockState state = getTileEntity().getBlockState();
|
||||
Block block = state.getBlock();
|
||||
BlockPos pos = getTileEntity().getPos();
|
||||
BlockPos pos = getTileEntity().getBlockPos();
|
||||
if (block == Blocks.ENCHANTING_TABLE)
|
||||
{
|
||||
bb = new AxisAlignedBB(pos, pos.add(1, 1, 1));
|
||||
bb = new AxisAlignedBB(pos, pos.offset(1, 1, 1));
|
||||
}
|
||||
else if (block == Blocks.CHEST || block == Blocks.TRAPPED_CHEST)
|
||||
{
|
||||
bb = new AxisAlignedBB(pos.add(-1, 0, -1), pos.add(2, 2, 2));
|
||||
bb = new AxisAlignedBB(pos.offset(-1, 0, -1), pos.offset(2, 2, 2));
|
||||
}
|
||||
else if (block == Blocks.STRUCTURE_BLOCK)
|
||||
{
|
||||
@@ -140,10 +140,10 @@ public interface IForgeTileEntity extends ICapabilitySerializable<CompoundNBT>
|
||||
AxisAlignedBB cbb = null;
|
||||
try
|
||||
{
|
||||
VoxelShape collisionShape = state.getCollisionShape(getTileEntity().getWorld(), pos);
|
||||
VoxelShape collisionShape = state.getCollisionShape(getTileEntity().getLevel(), pos);
|
||||
if (!collisionShape.isEmpty())
|
||||
{
|
||||
cbb = collisionShape.getBoundingBox().offset(pos);
|
||||
cbb = collisionShape.bounds().move(pos);
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
@@ -154,7 +154,7 @@ public interface IForgeTileEntity extends ICapabilitySerializable<CompoundNBT>
|
||||
// So, once again in the long line of US having to accommodate BUKKIT breaking things,
|
||||
// here it is, assume that the TE is only 1 cubic block. Problem with this is that it may
|
||||
// cause the TileEntity renderer to error further down the line! But alas, nothing we can do.
|
||||
cbb = new net.minecraft.util.math.AxisAlignedBB(pos.add(-1, 0, -1), pos.add(1, 1, 1));
|
||||
cbb = new net.minecraft.util.math.AxisAlignedBB(pos.offset(-1, 0, -1), pos.offset(1, 1, 1));
|
||||
}
|
||||
if (cbb != null) bb = cbb;
|
||||
}
|
||||
@@ -168,8 +168,8 @@ public interface IForgeTileEntity extends ICapabilitySerializable<CompoundNBT>
|
||||
default void requestModelDataUpdate()
|
||||
{
|
||||
TileEntity te = getTileEntity();
|
||||
World world = te.getWorld();
|
||||
if (world != null && world.isRemote)
|
||||
World world = te.getLevel();
|
||||
if (world != null && world.isClientSide)
|
||||
{
|
||||
ModelDataManager.requestModelDataRefresh(te);
|
||||
}
|
||||
|
||||
@@ -79,7 +79,7 @@ public abstract class GlobalLootModifierSerializer<T extends IGlobalLootModifier
|
||||
*/
|
||||
public JsonObject makeConditions(ILootCondition[] conditions) {
|
||||
JsonObject json = new JsonObject();
|
||||
json.add("conditions", ConditionArraySerializer.field_235679_a_.func_235681_a_(conditions));
|
||||
json.add("conditions", ConditionArraySerializer.INSTANCE.serializeConditions(conditions));
|
||||
return json;
|
||||
}
|
||||
|
||||
|
||||
@@ -44,7 +44,7 @@ public abstract class LootModifier implements IGlobalLootModifier {
|
||||
*/
|
||||
protected LootModifier(ILootCondition[] conditionsIn) {
|
||||
this.conditions = conditionsIn;
|
||||
this.combinedConditions = LootConditionManager.and(conditionsIn);
|
||||
this.combinedConditions = LootConditionManager.andConditions(conditionsIn);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
|
||||
@@ -53,7 +53,7 @@ import net.minecraftforge.registries.ForgeRegistries;
|
||||
|
||||
public class LootModifierManager extends JsonReloadListener {
|
||||
public static final Logger LOGGER = LogManager.getLogger();
|
||||
private static final Gson GSON_INSTANCE = LootSerializers.func_237387_b_().create();
|
||||
private static final Gson GSON_INSTANCE = LootSerializers.createFunctionSerializer().create();
|
||||
|
||||
private Map<ResourceLocation, IGlobalLootModifier> registeredLootModifiers = ImmutableMap.of();
|
||||
private static final String folder = "loot_modifiers";
|
||||
@@ -84,7 +84,7 @@ public class LootModifierManager extends JsonReloadListener {
|
||||
ResourceLocation resourcelocation = new ResourceLocation("forge","loot_modifiers/global_loot_modifiers.json");
|
||||
try {
|
||||
//read in all data files from forge:loot_modifiers/global_loot_modifiers in order to do layering
|
||||
for(IResource iresource : resourceManagerIn.getAllResources(resourcelocation)) {
|
||||
for(IResource iresource : resourceManagerIn.getResources(resourcelocation)) {
|
||||
try ( InputStream inputstream = iresource.getInputStream();
|
||||
Reader reader = new BufferedReader(new InputStreamReader(inputstream, StandardCharsets.UTF_8));
|
||||
) {
|
||||
@@ -101,7 +101,7 @@ public class LootModifierManager extends JsonReloadListener {
|
||||
}
|
||||
|
||||
catch (RuntimeException | IOException ioexception) {
|
||||
LOGGER.error("Couldn't read global loot modifier list {} in data pack {}", resourcelocation, iresource.getPackName(), ioexception);
|
||||
LOGGER.error("Couldn't read global loot modifier list {} in data pack {}", resourcelocation, iresource.getSourceName(), ioexception);
|
||||
} finally {
|
||||
IOUtils.closeQuietly((Closeable)iresource);
|
||||
}
|
||||
@@ -133,7 +133,7 @@ public class LootModifierManager extends JsonReloadListener {
|
||||
ResourceLocation serializer = location;
|
||||
if (object.has("type"))
|
||||
{
|
||||
serializer = new ResourceLocation(JSONUtils.getString(object, "type"));
|
||||
serializer = new ResourceLocation(JSONUtils.getAsString(object, "type"));
|
||||
}
|
||||
|
||||
return ForgeRegistries.LOOT_MODIFIER_SERIALIZERS.getValue(serializer).read(location, object, lootConditions);
|
||||
|
||||
@@ -43,7 +43,7 @@ public class LootTableIdCondition implements ILootCondition
|
||||
}
|
||||
|
||||
@Override
|
||||
public LootConditionType func_230419_b_()
|
||||
public LootConditionType getType()
|
||||
{
|
||||
return LOOT_TABLE_ID;
|
||||
}
|
||||
@@ -87,7 +87,7 @@ public class LootTableIdCondition implements ILootCondition
|
||||
@Override
|
||||
public LootTableIdCondition deserialize(JsonObject object, JsonDeserializationContext ctx)
|
||||
{
|
||||
return new LootTableIdCondition(new ResourceLocation(JSONUtils.getString(object, "loot_table_id")));
|
||||
return new LootTableIdCondition(new ResourceLocation(JSONUtils.getAsString(object, "loot_table_id")));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -36,14 +36,14 @@ public final class TransformationHelper
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public static TransformationMatrix toTransformation(ItemTransformVec3f transform)
|
||||
{
|
||||
if (transform.equals(ItemTransformVec3f.DEFAULT)) return TransformationMatrix.identity();
|
||||
if (transform.equals(ItemTransformVec3f.NO_TRANSFORM)) return TransformationMatrix.identity();
|
||||
|
||||
return new TransformationMatrix(transform.translation, quatFromXYZ(transform.rotation, true), transform.scale, null);
|
||||
}
|
||||
|
||||
public static Quaternion quatFromXYZ(Vector3f xyz, boolean degrees)
|
||||
{
|
||||
return new Quaternion(xyz.getX(), xyz.getY(), xyz.getZ(), degrees);
|
||||
return new Quaternion(xyz.x(), xyz.y(), xyz.z(), degrees);
|
||||
}
|
||||
|
||||
public static Quaternion quatFromXYZ(float[] xyz, boolean degrees)
|
||||
@@ -74,19 +74,19 @@ public final class TransformationHelper
|
||||
// the shorter path. Note that v1 and -v1 are equivalent when
|
||||
// the negation is applied to all four components. Fix by
|
||||
// reversing one quaternion.
|
||||
float dot = v0.getX() * v1.getX() + v0.getY() * v1.getY() + v0.getZ() * v1.getZ() + v0.getW() * v1.getW();
|
||||
float dot = v0.i() * v1.i() + v0.j() * v1.j() + v0.k() * v1.k() + v0.r() * v1.r();
|
||||
if (dot < 0.0f) {
|
||||
v1 = new Quaternion(-v1.getX(), -v1.getY(), -v1.getZ(), -v1.getW());
|
||||
v1 = new Quaternion(-v1.i(), -v1.j(), -v1.k(), -v1.r());
|
||||
dot = -dot;
|
||||
}
|
||||
|
||||
// If the inputs are too close for comfort, linearly interpolate
|
||||
// and normalize the result.
|
||||
if (dot > THRESHOLD) {
|
||||
float x = MathHelper.lerp(t, v0.getX(), v1.getX());
|
||||
float y = MathHelper.lerp(t, v0.getY(), v1.getY());
|
||||
float z = MathHelper.lerp(t, v0.getZ(), v1.getZ());
|
||||
float w = MathHelper.lerp(t, v0.getW(), v1.getW());
|
||||
float x = MathHelper.lerp(t, v0.i(), v1.i());
|
||||
float y = MathHelper.lerp(t, v0.j(), v1.j());
|
||||
float z = MathHelper.lerp(t, v0.k(), v1.k());
|
||||
float w = MathHelper.lerp(t, v0.r(), v1.r());
|
||||
return new Quaternion(x,y,z,w);
|
||||
}
|
||||
|
||||
@@ -101,10 +101,10 @@ public final class TransformationHelper
|
||||
float s0 = sin1t / sin01;
|
||||
|
||||
return new Quaternion(
|
||||
s0 * v0.getX() + s1 * v1.getX(),
|
||||
s0 * v0.getY() + s1 * v1.getY(),
|
||||
s0 * v0.getZ() + s1 * v1.getZ(),
|
||||
s0 * v0.getW() + s1 * v1.getW()
|
||||
s0 * v0.i() + s1 * v1.i(),
|
||||
s0 * v0.j() + s1 * v1.j(),
|
||||
s0 * v0.k() + s1 * v1.k(),
|
||||
s0 * v0.r() + s1 * v1.r()
|
||||
);
|
||||
}
|
||||
|
||||
@@ -112,7 +112,7 @@ public final class TransformationHelper
|
||||
{
|
||||
return new TransformationMatrix(
|
||||
lerp(one.getTranslation(), that.getTranslation(), progress),
|
||||
slerp(one.getRotationLeft(), that.getRotationLeft(), progress),
|
||||
slerp(one.getLeftRotation(), that.getLeftRotation(), progress),
|
||||
lerp(one.getScale(), that.getScale(), progress),
|
||||
slerp(one.getRightRot(), that.getRightRot(), progress)
|
||||
);
|
||||
@@ -120,10 +120,10 @@ public final class TransformationHelper
|
||||
|
||||
public static boolean epsilonEquals(Vector4f v1, Vector4f v2, float epsilon)
|
||||
{
|
||||
return MathHelper.abs(v1.getX()-v2.getX()) < epsilon &&
|
||||
MathHelper.abs(v1.getY()-v2.getY()) < epsilon &&
|
||||
MathHelper.abs(v1.getZ()-v2.getZ()) < epsilon &&
|
||||
MathHelper.abs(v1.getW()-v2.getW()) < epsilon;
|
||||
return MathHelper.abs(v1.x()-v2.x()) < epsilon &&
|
||||
MathHelper.abs(v1.y()-v2.y()) < epsilon &&
|
||||
MathHelper.abs(v1.z()-v2.z()) < epsilon &&
|
||||
MathHelper.abs(v1.w()-v2.w()) < epsilon;
|
||||
}
|
||||
|
||||
public static class Deserializer implements JsonDeserializer<TransformationMatrix>
|
||||
@@ -348,7 +348,7 @@ public final class TransformationHelper
|
||||
Quaternion ret = Quaternion.ONE.copy();
|
||||
for (JsonElement a : e.getAsJsonArray())
|
||||
{
|
||||
ret.multiply(parseAxisRotation(a));
|
||||
ret.mul(parseAxisRotation(a));
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -82,7 +82,7 @@ public final class Clips
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getString()
|
||||
public String getSerializedName()
|
||||
{
|
||||
return "identity";
|
||||
}
|
||||
@@ -416,7 +416,7 @@ public final class Clips
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getString()
|
||||
public String getSerializedName()
|
||||
{
|
||||
return clipName;
|
||||
}
|
||||
@@ -475,7 +475,7 @@ public final class Clips
|
||||
// IdentityClip + ClipReference
|
||||
if(clip instanceof IStringSerializable)
|
||||
{
|
||||
out.value("#" + ((IStringSerializable)clip).getString());
|
||||
out.value("#" + ((IStringSerializable)clip).getSerializedName());
|
||||
return;
|
||||
}
|
||||
else if(clip instanceof TimeClip)
|
||||
|
||||
@@ -59,7 +59,7 @@ public class BlockSnapshot
|
||||
private BlockSnapshot(RegistryKey<World> dim, IWorld world, BlockPos pos, BlockState state, @Nullable CompoundNBT nbt, int flags)
|
||||
{
|
||||
this.dim = dim;
|
||||
this.pos = pos.toImmutable();
|
||||
this.pos = pos.immutable();
|
||||
this.block = state;
|
||||
this.flags = flags;
|
||||
this.nbt = nbt;
|
||||
@@ -77,19 +77,19 @@ public class BlockSnapshot
|
||||
|
||||
public static BlockSnapshot create(RegistryKey<World> dim, IWorld world, BlockPos pos, int flag)
|
||||
{
|
||||
return new BlockSnapshot(dim, world, pos, world.getBlockState(pos), getTileNBT(world.getTileEntity(pos)), flag);
|
||||
return new BlockSnapshot(dim, world, pos, world.getBlockState(pos), getTileNBT(world.getBlockEntity(pos)), flag);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static CompoundNBT getTileNBT(@Nullable TileEntity te)
|
||||
{
|
||||
return te == null ? null : te.write(new CompoundNBT());
|
||||
return te == null ? null : te.save(new CompoundNBT());
|
||||
}
|
||||
|
||||
public BlockState getCurrentBlock()
|
||||
{
|
||||
IWorld world = getWorld();
|
||||
return world == null ? Blocks.AIR.getDefaultState() : world.getBlockState(this.pos);
|
||||
return world == null ? Blocks.AIR.defaultBlockState() : world.getBlockState(this.pos);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@@ -98,7 +98,7 @@ public class BlockSnapshot
|
||||
IWorld world = this.world != null ? this.world.get() : null;
|
||||
if (world == null)
|
||||
{
|
||||
world = ServerLifecycleHooks.getCurrentServer().getWorld(this.dim);
|
||||
world = ServerLifecycleHooks.getCurrentServer().getLevel(this.dim);
|
||||
this.world = new WeakReference<IWorld>(world);
|
||||
}
|
||||
return world;
|
||||
@@ -112,7 +112,7 @@ public class BlockSnapshot
|
||||
@Nullable
|
||||
public TileEntity getTileEntity()
|
||||
{
|
||||
return getNbt() != null ? TileEntity.readTileEntity(getReplacedBlock(), getNbt()) : null;
|
||||
return getNbt() != null ? TileEntity.loadStatic(getReplacedBlock(), getNbt()) : null;
|
||||
}
|
||||
|
||||
public boolean restore()
|
||||
@@ -140,23 +140,23 @@ public class BlockSnapshot
|
||||
if (current != replaced)
|
||||
{
|
||||
if (force)
|
||||
world.setBlockState(pos, replaced, flags);
|
||||
world.setBlock(pos, replaced, flags);
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
world.setBlockState(pos, replaced, flags);
|
||||
world.setBlock(pos, replaced, flags);
|
||||
if (world instanceof World)
|
||||
((World)world).notifyBlockUpdate(pos, current, replaced, flags);
|
||||
((World)world).sendBlockUpdated(pos, current, replaced, flags);
|
||||
|
||||
TileEntity te = null;
|
||||
if (getNbt() != null)
|
||||
{
|
||||
te = world.getTileEntity(pos);
|
||||
te = world.getBlockEntity(pos);
|
||||
if (te != null)
|
||||
{
|
||||
te.read(getReplacedBlock(), getNbt());
|
||||
te.markDirty();
|
||||
te.load(getReplacedBlock(), getNbt());
|
||||
te.setChanged();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -200,7 +200,7 @@ public class BlockSnapshot
|
||||
{
|
||||
this.toString =
|
||||
"BlockSnapshot[" +
|
||||
"World:" + this.dim.getLocation() + ',' +
|
||||
"World:" + this.dim.location() + ',' +
|
||||
"Pos: " + this.pos + ',' +
|
||||
"State: " + this.block + ',' +
|
||||
"Flags: " + this.flags + ',' +
|
||||
|
||||
@@ -30,8 +30,8 @@ public class ChunkCoordComparator implements java.util.Comparator<ChunkPos>
|
||||
|
||||
public ChunkCoordComparator(ServerPlayerEntity entityplayer)
|
||||
{
|
||||
x = (int) entityplayer.getPosX() >> 4;
|
||||
z = (int) entityplayer.getPosZ() >> 4;
|
||||
x = (int) entityplayer.getX() >> 4;
|
||||
z = (int) entityplayer.getZ() >> 4;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -29,12 +29,12 @@ public class DummyWorldSaveData extends WorldSavedData {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void read(final CompoundNBT nbt) {
|
||||
public void load(final CompoundNBT nbt) {
|
||||
// NOOP
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompoundNBT write(final CompoundNBT compound) {
|
||||
public CompoundNBT save(final CompoundNBT compound) {
|
||||
// NOOP
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -47,16 +47,16 @@ public class FakePlayer extends ServerPlayerEntity
|
||||
super(world.getServer(), world, name, new PlayerInteractionManager(world));
|
||||
}
|
||||
|
||||
@Override public Vector3d getPositionVec(){ return new Vector3d(0, 0, 0); }
|
||||
@Override public BlockPos getPosition(){ return BlockPos.ZERO; }
|
||||
@Override public void sendStatusMessage(ITextComponent chatComponent, boolean actionBar){}
|
||||
@Override public Vector3d position(){ return new Vector3d(0, 0, 0); }
|
||||
@Override public BlockPos blockPosition(){ return BlockPos.ZERO; }
|
||||
@Override public void displayClientMessage(ITextComponent chatComponent, boolean actionBar){}
|
||||
@Override public void sendMessage(ITextComponent component, UUID senderUUID) {}
|
||||
@Override public void addStat(Stat par1StatBase, int par2){}
|
||||
@Override public void awardStat(Stat par1StatBase, int par2){}
|
||||
//@Override public void openGui(Object mod, int modGuiId, World world, int x, int y, int z){}
|
||||
@Override public boolean isInvulnerableTo(DamageSource source){ return true; }
|
||||
@Override public boolean canAttackPlayer(PlayerEntity player){ return false; }
|
||||
@Override public void onDeath(DamageSource source){ return; }
|
||||
@Override public boolean canHarmPlayer(PlayerEntity player){ return false; }
|
||||
@Override public void die(DamageSource source){ return; }
|
||||
@Override public void tick(){ return; }
|
||||
@Override public void handleClientSettings(CClientSettingsPacket pkt){ return; }
|
||||
@Override public void updateOptions(CClientSettingsPacket pkt){ return; }
|
||||
@Override @Nullable public MinecraftServer getServer() { return ServerLifecycleHooks.getCurrentServer(); }
|
||||
}
|
||||
@@ -67,11 +67,11 @@ public class FakePlayerFactory
|
||||
|
||||
public static void unloadWorld(ServerWorld world)
|
||||
{
|
||||
fakePlayers.entrySet().removeIf(entry -> entry.getValue().world == world);
|
||||
if (MINECRAFT_PLAYER != null && MINECRAFT_PLAYER.get() != null && MINECRAFT_PLAYER.get().world == world) // This shouldn't be strictly necessary, but lets be aggressive.
|
||||
fakePlayers.entrySet().removeIf(entry -> entry.getValue().level == world);
|
||||
if (MINECRAFT_PLAYER != null && MINECRAFT_PLAYER.get() != null && MINECRAFT_PLAYER.get().level == world) // This shouldn't be strictly necessary, but lets be aggressive.
|
||||
{
|
||||
FakePlayer mc = MINECRAFT_PLAYER.get();
|
||||
if (mc != null && mc.world == world)
|
||||
if (mc != null && mc.level == world)
|
||||
{
|
||||
MINECRAFT_PLAYER = null;
|
||||
}
|
||||
|
||||
@@ -81,7 +81,7 @@ public interface ITeleporter
|
||||
@Nullable
|
||||
default PortalInfo getPortalInfo(Entity entity, ServerWorld destWorld, Function<ServerWorld, PortalInfo> defaultPortalInfo)
|
||||
{
|
||||
return this.isVanilla() ? defaultPortalInfo.apply(destWorld) : new PortalInfo(entity.getPositionVec(), Vector3d.ZERO, entity.rotationYaw, entity.rotationPitch);
|
||||
return this.isVanilla() ? defaultPortalInfo.apply(destWorld) : new PortalInfo(entity.position(), Vector3d.ZERO, entity.yRot, entity.xRot);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -99,11 +99,11 @@ public class JsonUtils
|
||||
@Nullable
|
||||
public static CompoundNBT readNBT(JsonObject json, String key)
|
||||
{
|
||||
if (net.minecraft.util.JSONUtils.hasField(json, key))
|
||||
if (net.minecraft.util.JSONUtils.isValidNode(json, key))
|
||||
{
|
||||
try
|
||||
{
|
||||
return JsonToNBT.getTagFromJson(net.minecraft.util.JSONUtils.getString(json, key));
|
||||
return JsonToNBT.parseTag(net.minecraft.util.JSONUtils.getAsString(json, key));
|
||||
} catch (CommandSyntaxException e)
|
||||
{
|
||||
throw new JsonSyntaxException("Malformed NBT tag", e);
|
||||
|
||||
@@ -47,10 +47,10 @@ public class ReverseTagWrapper<T>
|
||||
public Set<ResourceLocation> getTagNames()
|
||||
{
|
||||
ITagCollection<T> collection = colSupplier.get();
|
||||
if (cache == null || colCache != collection.getIDTagMap()) // Identity equals.
|
||||
if (cache == null || colCache != collection.getAllTags()) // Identity equals.
|
||||
{
|
||||
this.cache = Collections.unmodifiableSet(new HashSet<>(collection.getOwningTags(target)));
|
||||
this.colCache = collection.getIDTagMap();
|
||||
this.cache = Collections.unmodifiableSet(new HashSet<>(collection.getMatchingTags(target)));
|
||||
this.colCache = collection.getAllTags();
|
||||
}
|
||||
return this.cache;
|
||||
}
|
||||
|
||||
@@ -43,7 +43,7 @@ public class WorldCapabilityData extends WorldSavedData
|
||||
}
|
||||
|
||||
@Override
|
||||
public void read(CompoundNBT nbt)
|
||||
public void load(CompoundNBT nbt)
|
||||
{
|
||||
this.capNBT = nbt;
|
||||
if (serializable != null)
|
||||
@@ -54,7 +54,7 @@ public class WorldCapabilityData extends WorldSavedData
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompoundNBT write(CompoundNBT nbt)
|
||||
public CompoundNBT save(CompoundNBT nbt)
|
||||
{
|
||||
if (serializable != null)
|
||||
nbt = serializable.serializeNBT();
|
||||
|
||||
@@ -39,12 +39,12 @@ public class BiomeGenerationSettingsBuilder extends BiomeGenerationSettings.Buil
|
||||
{
|
||||
surfaceBuilder = Optional.of(orig.getSurfaceBuilder());
|
||||
orig.getCarvingStages().forEach(k -> carvers.put(k, new ArrayList<>(orig.getCarvers(k))));
|
||||
orig.getFeatures().forEach(l -> features.add(new ArrayList<>(l)));
|
||||
structures.addAll(orig.getStructures());
|
||||
orig.features().forEach(l -> features.add(new ArrayList<>(l)));
|
||||
structureStarts.addAll(orig.structures());
|
||||
}
|
||||
|
||||
public List<Supplier<ConfiguredFeature<?, ?>>> getFeatures(GenerationStage.Decoration stage) {
|
||||
populateStageEntries(stage.ordinal());
|
||||
addFeatureStepsUpTo(stage.ordinal());
|
||||
return features.get(stage.ordinal());
|
||||
}
|
||||
|
||||
@@ -57,6 +57,6 @@ public class BiomeGenerationSettingsBuilder extends BiomeGenerationSettings.Buil
|
||||
}
|
||||
|
||||
public List<Supplier<StructureFeature<?, ?>>> getStructures() {
|
||||
return structures;
|
||||
return structureStarts;
|
||||
}
|
||||
}
|
||||
@@ -77,7 +77,7 @@ public class ForgeChunkManager
|
||||
*/
|
||||
public static boolean hasForcedChunks(ServerWorld world)
|
||||
{
|
||||
ForcedChunksSaveData data = world.getSavedData().get(ForcedChunksSaveData::new, "chunks");
|
||||
ForcedChunksSaveData data = world.getDataStorage().get(ForcedChunksSaveData::new, "chunks");
|
||||
if (data == null) return false;
|
||||
return !data.getChunks().isEmpty() || !data.getBlockForcedChunks().isEmpty() || !data.getEntityForcedChunks().isEmpty();
|
||||
}
|
||||
@@ -101,7 +101,7 @@ public class ForgeChunkManager
|
||||
*/
|
||||
public static boolean forceChunk(ServerWorld world, String modId, Entity owner, int chunkX, int chunkZ, boolean add, boolean ticking)
|
||||
{
|
||||
return forceChunk(world, modId, owner.getUniqueID(), chunkX, chunkZ, add, ticking);
|
||||
return forceChunk(world, modId, owner.getUUID(), chunkX, chunkZ, add, ticking);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -130,9 +130,9 @@ public class ForgeChunkManager
|
||||
LOGGER.warn("A mod attempted to force a chunk for an unloaded mod of id: {}", modId);
|
||||
return false;
|
||||
}
|
||||
ForcedChunksSaveData saveData = world.getSavedData().getOrCreate(ForcedChunksSaveData::new, "chunks");
|
||||
ForcedChunksSaveData saveData = world.getDataStorage().computeIfAbsent(ForcedChunksSaveData::new, "chunks");
|
||||
ChunkPos pos = new ChunkPos(chunkX, chunkZ);
|
||||
long chunk = pos.asLong();
|
||||
long chunk = pos.toLong();
|
||||
TicketTracker<T> tickets = ticketGetter.apply(saveData);
|
||||
TicketOwner<T> ticketOwner = new TicketOwner<>(modId, owner);
|
||||
boolean success;
|
||||
@@ -169,14 +169,14 @@ public class ForgeChunkManager
|
||||
if (add)
|
||||
{
|
||||
if (ticking)
|
||||
world.getChunkProvider().registerTickingTicket(type, pos, 2, owner);
|
||||
world.getChunkSource().registerTickingTicket(type, pos, 2, owner);
|
||||
else
|
||||
world.getChunkProvider().registerTicket(type, pos, 2, owner);
|
||||
world.getChunkSource().addRegionTicket(type, pos, 2, owner);
|
||||
}
|
||||
else if (ticking)
|
||||
world.getChunkProvider().releaseTickingTicket(type, pos, 2, owner);
|
||||
world.getChunkSource().releaseTickingTicket(type, pos, 2, owner);
|
||||
else
|
||||
world.getChunkProvider().releaseTicket(type, pos, 2, owner);
|
||||
world.getChunkSource().removeRegionTicket(type, pos, 2, owner);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -264,7 +264,7 @@ public class ForgeChunkManager
|
||||
{
|
||||
Map<String, Long2ObjectMap<CompoundNBT>> forcedEntries = new HashMap<>();
|
||||
writeForcedChunkOwners(forcedEntries, blockForcedChunks, "Blocks", Constants.NBT.TAG_COMPOUND, (pos, forcedBlocks) -> forcedBlocks.add(NBTUtil.writeBlockPos(pos)));
|
||||
writeForcedChunkOwners(forcedEntries, entityForcedChunks, "Entities", Constants.NBT.TAG_INT_ARRAY, (uuid, forcedEntities) -> forcedEntities.add(NBTUtil.func_240626_a_(uuid)));
|
||||
writeForcedChunkOwners(forcedEntries, entityForcedChunks, "Entities", Constants.NBT.TAG_INT_ARRAY, (uuid, forcedEntities) -> forcedEntities.add(NBTUtil.createUUID(uuid)));
|
||||
ListNBT forcedChunks = new ListNBT();
|
||||
for (Map.Entry<String, Long2ObjectMap<CompoundNBT>> entry : forcedEntries.entrySet())
|
||||
{
|
||||
@@ -361,7 +361,7 @@ public class ForgeChunkManager
|
||||
ListNBT forcedEntities = modEntry.getList(key, Constants.NBT.TAG_INT_ARRAY);
|
||||
for (INBT uuid : forcedEntities)
|
||||
{
|
||||
entityForcedChunks.computeIfAbsent(new TicketOwner<>(modId, NBTUtil.readUniqueId(uuid)), owner -> new LongOpenHashSet()).add(chunkPos);
|
||||
entityForcedChunks.computeIfAbsent(new TicketOwner<>(modId, NBTUtil.loadUUID(uuid)), owner -> new LongOpenHashSet()).add(chunkPos);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -71,7 +71,7 @@ public class ForgeWorldType extends ForgeRegistryEntry<ForgeWorldType>
|
||||
|
||||
public String getTranslationKey()
|
||||
{
|
||||
return Util.makeTranslationKey("generator", getRegistryName());
|
||||
return Util.makeDescriptionId("generator", getRegistryName());
|
||||
}
|
||||
|
||||
public ITextComponent getDisplayName()
|
||||
@@ -99,12 +99,12 @@ public class ForgeWorldType extends ForgeRegistryEntry<ForgeWorldType>
|
||||
ChunkGenerator createChunkGenerator(Registry<Biome> biomeRegistry, Registry<DimensionSettings> dimensionSettingsRegistry, long seed, String generatorSettings);
|
||||
|
||||
default DimensionGeneratorSettings createSettings(DynamicRegistries dynamicRegistries, long seed, boolean generateStructures, boolean bonusChest, String generatorSettings) {
|
||||
Registry<Biome> biomeRegistry = dynamicRegistries.getRegistry(Registry.BIOME_KEY);
|
||||
Registry<DimensionType> dimensionTypeRegistry = dynamicRegistries.getRegistry(Registry.DIMENSION_TYPE_KEY);
|
||||
Registry<DimensionSettings> dimensionSettingsRegistry = dynamicRegistries.getRegistry(Registry.NOISE_SETTINGS_KEY);
|
||||
Registry<Biome> biomeRegistry = dynamicRegistries.registryOrThrow(Registry.BIOME_REGISTRY);
|
||||
Registry<DimensionType> dimensionTypeRegistry = dynamicRegistries.registryOrThrow(Registry.DIMENSION_TYPE_REGISTRY);
|
||||
Registry<DimensionSettings> dimensionSettingsRegistry = dynamicRegistries.registryOrThrow(Registry.NOISE_GENERATOR_SETTINGS_REGISTRY);
|
||||
return new DimensionGeneratorSettings(seed, generateStructures, bonusChest,
|
||||
DimensionGeneratorSettings.func_242749_a(dimensionTypeRegistry,
|
||||
DimensionType.getDefaultSimpleRegistry(dimensionTypeRegistry, biomeRegistry, dimensionSettingsRegistry, seed),
|
||||
DimensionGeneratorSettings.withOverworld(dimensionTypeRegistry,
|
||||
DimensionType.defaultDimensions(dimensionTypeRegistry, biomeRegistry, dimensionSettingsRegistry, seed),
|
||||
createChunkGenerator(biomeRegistry, dimensionSettingsRegistry, seed, generatorSettings)));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,17 +32,17 @@ import net.minecraft.world.biome.MobSpawnInfo;
|
||||
public class MobSpawnInfoBuilder extends MobSpawnInfo.Builder
|
||||
{
|
||||
private final Set<EntityClassification> typesView = Collections.unmodifiableSet(this.spawners.keySet());
|
||||
private final Set<EntityType<?>> costView = Collections.unmodifiableSet(this.spawnCosts.keySet());
|
||||
private final Set<EntityType<?>> costView = Collections.unmodifiableSet(this.mobSpawnCosts.keySet());
|
||||
|
||||
public MobSpawnInfoBuilder(MobSpawnInfo orig)
|
||||
{
|
||||
orig.getSpawnerTypes().forEach(k -> {
|
||||
spawners.get(k).clear();
|
||||
spawners.get(k).addAll(new java.util.ArrayList<>(orig.getSpawners(k)));
|
||||
spawners.get(k).addAll(new java.util.ArrayList<>(orig.getMobs(k)));
|
||||
});
|
||||
orig.getEntityTypes().forEach(k -> spawnCosts.put(k, orig.getSpawnCost(k)));
|
||||
creatureSpawnProbability = orig.getCreatureSpawnProbability();
|
||||
validSpawnBiomeForPlayer = orig.isValidSpawnBiomeForPlayer();
|
||||
orig.getEntityTypes().forEach(k -> mobSpawnCosts.put(k, orig.getMobSpawnCost(k)));
|
||||
creatureGenerationProbability = orig.getCreatureProbability();
|
||||
playerCanSpawn = orig.playerSpawnFriendly();
|
||||
}
|
||||
|
||||
public Set<EntityClassification> getSpawnerTypes()
|
||||
@@ -63,17 +63,17 @@ public class MobSpawnInfoBuilder extends MobSpawnInfo.Builder
|
||||
@Nullable
|
||||
public MobSpawnInfo.SpawnCosts getCost(EntityType<?> type)
|
||||
{
|
||||
return this.spawnCosts.get(type);
|
||||
return this.mobSpawnCosts.get(type);
|
||||
}
|
||||
|
||||
public float getProbability()
|
||||
{
|
||||
return this.creatureSpawnProbability;
|
||||
return this.creatureGenerationProbability;
|
||||
}
|
||||
|
||||
public MobSpawnInfoBuilder disablePlayerSpawn()
|
||||
{
|
||||
this.validSpawnBiomeForPlayer = false;
|
||||
this.playerCanSpawn = false;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
@@ -55,12 +55,12 @@ public class StructureSpawnManager
|
||||
Map<Structure<?>, StructureSpawnInfo> structuresWithSpawns = new LinkedHashMap<>();
|
||||
gatherEntitySpawns(structuresWithSpawns, Structure.SWAMP_HUT);
|
||||
gatherEntitySpawns(structuresWithSpawns, Structure.PILLAGER_OUTPOST);
|
||||
gatherEntitySpawns(structuresWithSpawns, Structure.MONUMENT);
|
||||
gatherEntitySpawns(structuresWithSpawns, Structure.FORTRESS);
|
||||
gatherEntitySpawns(structuresWithSpawns, Structure.OCEAN_MONUMENT);
|
||||
gatherEntitySpawns(structuresWithSpawns, Structure.NETHER_BRIDGE);
|
||||
for (Structure<?> structure : ForgeRegistries.STRUCTURE_FEATURES.getValues())
|
||||
{
|
||||
if (structure != Structure.SWAMP_HUT && structure != Structure.PILLAGER_OUTPOST && structure != Structure.MONUMENT &&
|
||||
structure != Structure.FORTRESS)
|
||||
if (structure != Structure.SWAMP_HUT && structure != Structure.PILLAGER_OUTPOST && structure != Structure.OCEAN_MONUMENT &&
|
||||
structure != Structure.NETHER_BRIDGE)
|
||||
{
|
||||
//If we didn't already gather the spawns already to ensure we do vanilla ones already
|
||||
// gather the spawns for this structure
|
||||
@@ -99,7 +99,7 @@ public class StructureSpawnManager
|
||||
Structure<?> structure = entry.getKey();
|
||||
StructureSpawnInfo spawnInfo = entry.getValue();
|
||||
//Note: We check if the structure has spawns for a type first before looking at the world as it should be a cheaper check
|
||||
if (spawnInfo.spawns.containsKey(classification) && structureManager.getStructureStart(pos, spawnInfo.insideOnly, structure).isValid())
|
||||
if (spawnInfo.spawns.containsKey(classification) && structureManager.getStructureAt(pos, spawnInfo.insideOnly, structure).isValid())
|
||||
return spawnInfo.spawns.get(classification);
|
||||
}
|
||||
return null;
|
||||
|
||||
Reference in new issue
Block a user