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:
LexManos committed 2021-03-09 14:21:48 -08:00
1 parent 802298d99d
commit a95b968c13
832 files changed
+4464 -4373

No files matched your search

@@ -161,7 +161,7 @@ public class ForgeHooksClient
public static void onTextureStitchedPre(AtlasTexture map, Set<ResourceLocation> resourceLocations)
{
StartupMessageManager.mcLoaderConsumer().ifPresent(c->c.accept("Atlas Stitching : "+map.getTextureLocation().toString()));
StartupMessageManager.mcLoaderConsumer().ifPresent(c->c.accept("Atlas Stitching : "+map.location().toString()));
ModLoader.get().postEvent(new TextureStitchEvent.Pre(map, resourceLocations));
// ModelLoader.White.INSTANCE.register(map); // TODO Custom TAS
}
@@ -254,10 +254,10 @@ public class ForgeHooksClient
if (status == BETA || status == BETA_OUTDATED)
{
// render a warning at the top of the screen,
ITextComponent line = new TranslationTextComponent("forge.update.beta.1", TextFormatting.RED, TextFormatting.RESET).mergeStyle(TextFormatting.RED);
AbstractGui.drawCenteredString(mStack, font, line, width / 2, 4 + (0 * (font.FONT_HEIGHT + 1)), 0xFFFFFF | alpha);
ITextComponent line = new TranslationTextComponent("forge.update.beta.1", TextFormatting.RED, TextFormatting.RESET).withStyle(TextFormatting.RED);
AbstractGui.drawCenteredString(mStack, font, line, width / 2, 4 + (0 * (font.lineHeight + 1)), 0xFFFFFF | alpha);
line = new TranslationTextComponent("forge.update.beta.2");
AbstractGui.drawCenteredString(mStack, font, line, width / 2, 4 + (1 * (font.FONT_HEIGHT + 1)), 0xFFFFFF | alpha);
AbstractGui.drawCenteredString(mStack, font, line, width / 2, 4 + (1 * (font.lineHeight + 1)), 0xFFFFFF | alpha);
}
String line = null;
@@ -267,7 +267,7 @@ public class ForgeHooksClient
//case UP_TO_DATE: line = "Forge up to date"}; break;
//case AHEAD: line = "Using non-recommended Forge build, issues may arise."}; break;
case OUTDATED:
case BETA_OUTDATED: line = I18n.format("forge.update.newversion", ForgeVersion.getTarget()); break;
case BETA_OUTDATED: line = I18n.get("forge.update.newversion", ForgeVersion.getTarget()); break;
default: break;
}
@@ -311,7 +311,7 @@ public class ForgeHooksClient
public static EntityViewRenderEvent.CameraSetup onCameraSetup(GameRenderer renderer, ActiveRenderInfo info, float partial)
{
EntityViewRenderEvent.CameraSetup event = new EntityViewRenderEvent.CameraSetup(renderer, info, partial, info.getYaw(), info.getPitch(), 0);
EntityViewRenderEvent.CameraSetup event = new EntityViewRenderEvent.CameraSetup(renderer, info, partial, info.getYRot(), info.getXRot(), 0);
MinecraftForge.EVENT_BUS.post(event);
return event;
}
@@ -325,7 +325,7 @@ public class ForgeHooksClient
private static final Matrix4f flipX;
private static final Matrix3f flipXNormal;
static {
flipX = Matrix4f.makeScale(-1,1,1);
flipX = Matrix4f.createScaleMatrix(-1,1,1);
flipXNormal = new Matrix3f(flipX);
}
@@ -338,17 +338,17 @@ public class ForgeHooksClient
if (!stack.clear())
{
// Apply the transformation to the real matrix stack, flipping for left hand
Matrix4f tMat = stack.getLast().getMatrix();
Matrix3f nMat = stack.getLast().getNormal();
Matrix4f tMat = stack.last().pose();
Matrix3f nMat = stack.last().normal();
if (leftHandHackery)
{
tMat.multiplyBackward(flipX);
tMat.mul(flipX);
tMat.multiply(flipX);
nMat.multiplyBackward(flipXNormal);
nMat.mul(flipXNormal);
}
matrixStack.getLast().getMatrix().mul(tMat);
matrixStack.getLast().getNormal().mul(nMat);
matrixStack.last().pose().multiply(tMat);
matrixStack.last().normal().mul(nMat);
}
return model;
}
@@ -359,7 +359,7 @@ public class ForgeHooksClient
{
VertexFormatElement attr = format.getElements().get(element);
int count = attr.getElementCount();
int constant = attr.getType().getGlConstant();
int constant = attr.getType().getGlType();
((Buffer)buffer).position(format.getOffset(element));
switch(attrType)
{
@@ -392,7 +392,7 @@ public class ForgeHooksClient
glVertexAttribPointer(attr.getIndex(), count, constant, false, stride, buffer);
break;
default:
LOGGER.fatal("Unimplemented vanilla attribute upload: {}", attrType.getDisplayName());
LOGGER.fatal("Unimplemented vanilla attribute upload: {}", attrType.getName());
}
}
@@ -421,7 +421,7 @@ public class ForgeHooksClient
glDisableVertexAttribArray(attr.getIndex());
break;
default:
LOGGER.fatal("Unimplemented vanilla attribute upload: {}", attrType.getDisplayName());
LOGGER.fatal("Unimplemented vanilla attribute upload: {}", attrType.getName());
}
}
@@ -462,11 +462,11 @@ public class ForgeHooksClient
@SuppressWarnings("deprecation")
public static TextureAtlasSprite[] getFluidSprites(IBlockDisplayReader world, BlockPos pos, FluidState fluidStateIn)
{
ResourceLocation overlayTexture = fluidStateIn.getFluid().getAttributes().getOverlayTexture();
ResourceLocation overlayTexture = fluidStateIn.getType().getAttributes().getOverlayTexture();
return new TextureAtlasSprite[] {
Minecraft.getInstance().getAtlasSpriteGetter(AtlasTexture.LOCATION_BLOCKS_TEXTURE).apply(fluidStateIn.getFluid().getAttributes().getStillTexture(world, pos)),
Minecraft.getInstance().getAtlasSpriteGetter(AtlasTexture.LOCATION_BLOCKS_TEXTURE).apply(fluidStateIn.getFluid().getAttributes().getFlowingTexture(world, pos)),
overlayTexture == null ? null : Minecraft.getInstance().getAtlasSpriteGetter(AtlasTexture.LOCATION_BLOCKS_TEXTURE).apply(overlayTexture),
Minecraft.getInstance().getTextureAtlas(AtlasTexture.LOCATION_BLOCKS).apply(fluidStateIn.getType().getAttributes().getStillTexture(world, pos)),
Minecraft.getInstance().getTextureAtlas(AtlasTexture.LOCATION_BLOCKS).apply(fluidStateIn.getType().getAttributes().getFlowingTexture(world, pos)),
overlayTexture == null ? null : Minecraft.getInstance().getTextureAtlas(AtlasTexture.LOCATION_BLOCKS).apply(overlayTexture),
};
}
@@ -487,7 +487,7 @@ public class ForgeHooksClient
@SuppressWarnings("deprecation")
public static RenderMaterial getBlockMaterial(ResourceLocation loc)
{
return new RenderMaterial(AtlasTexture.LOCATION_BLOCKS_TEXTURE, loc);
return new RenderMaterial(AtlasTexture.LOCATION_BLOCKS, loc);
}
/**
@@ -505,9 +505,9 @@ public class ForgeHooksClient
v2.cross(v1);
v2.normalize();
int x = ((byte) Math.round(v2.getX() * 127)) & 0xFF;
int y = ((byte) Math.round(v2.getY() * 127)) & 0xFF;
int z = ((byte) Math.round(v2.getZ() * 127)) & 0xFF;
int x = ((byte) Math.round(v2.x() * 127)) & 0xFF;
int y = ((byte) Math.round(v2.y() * 127)) & 0xFF;
int z = ((byte) Math.round(v2.z() * 127)) & 0xFF;
int normal = x | (y << 0x08) | (z << 0x10);
@@ -535,7 +535,7 @@ public class ForgeHooksClient
ResourceLocation shader = ClientRegistry.getEntityShader(entity.getClass());
if (shader != null)
{
entityRenderer.loadShader(shader);
entityRenderer.loadEffect(shader);
}
}
}
@@ -591,7 +591,7 @@ public class ForgeHooksClient
@SuppressWarnings("deprecation")
public static IBakedModel handlePerspective(IBakedModel model, ItemCameraTransforms.TransformType type, MatrixStack stack)
{
TransformationMatrix tr = TransformationHelper.toTransformation(model.getItemCameraTransforms().getTransform(type));
TransformationMatrix tr = TransformationHelper.toTransformation(model.getTransforms().getTransform(type));
if(!tr.isIdentity()) {
tr.push(stack);
}
@@ -605,7 +605,7 @@ public class ForgeHooksClient
public static void refreshResources(Minecraft mc, VanillaResourceType... types) {
SelectiveReloadStateHandler.INSTANCE.beginReload(ReloadRequirements.include(types));
mc.reloadResources();
mc.reloadResourcePacks();
SelectiveReloadStateHandler.INSTANCE.endReload();
}
@@ -647,18 +647,18 @@ public class ForgeHooksClient
public static boolean onGuiMouseScrollPre(MouseHelper mouseHelper, Screen guiScreen, double scrollDelta)
{
MainWindow mainWindow = guiScreen.getMinecraft().getMainWindow();
double mouseX = mouseHelper.getMouseX() * (double) mainWindow.getScaledWidth() / (double) mainWindow.getWidth();
double mouseY = mouseHelper.getMouseY() * (double) mainWindow.getScaledHeight() / (double) mainWindow.getHeight();
MainWindow mainWindow = guiScreen.getMinecraft().getWindow();
double mouseX = mouseHelper.xpos() * (double) mainWindow.getGuiScaledWidth() / (double) mainWindow.getScreenWidth();
double mouseY = mouseHelper.ypos() * (double) mainWindow.getGuiScaledHeight() / (double) mainWindow.getScreenHeight();
Event event = new GuiScreenEvent.MouseScrollEvent.Pre(guiScreen, mouseX, mouseY, scrollDelta);
return MinecraftForge.EVENT_BUS.post(event);
}
public static boolean onGuiMouseScrollPost(MouseHelper mouseHelper, Screen guiScreen, double scrollDelta)
{
MainWindow mainWindow = guiScreen.getMinecraft().getMainWindow();
double mouseX = mouseHelper.getMouseX() * (double) mainWindow.getScaledWidth() / (double) mainWindow.getWidth();
double mouseY = mouseHelper.getMouseY() * (double) mainWindow.getScaledHeight() / (double) mainWindow.getHeight();
MainWindow mainWindow = guiScreen.getMinecraft().getWindow();
double mouseX = mouseHelper.xpos() * (double) mainWindow.getGuiScaledWidth() / (double) mainWindow.getScreenWidth();
double mouseY = mouseHelper.ypos() * (double) mainWindow.getGuiScaledHeight() / (double) mainWindow.getScreenHeight();
Event event = new GuiScreenEvent.MouseScrollEvent.Post(guiScreen, mouseX, mouseY, scrollDelta);
return MinecraftForge.EVENT_BUS.post(event);
}
@@ -737,7 +737,7 @@ public class ForgeHooksClient
public static boolean onMouseScroll(MouseHelper mouseHelper, double scrollDelta)
{
Event event = new InputEvent.MouseScrollEvent(scrollDelta, mouseHelper.isLeftDown(), mouseHelper.isMiddleDown(), mouseHelper.isRightDown(), mouseHelper.getMouseX(), mouseHelper.getMouseY());
Event event = new InputEvent.MouseScrollEvent(scrollDelta, mouseHelper.isLeftPressed(), mouseHelper.isMiddleDown(), mouseHelper.isRightPressed(), mouseHelper.xpos(), mouseHelper.ypos());
return MinecraftForge.EVENT_BUS.post(event);
}
@@ -764,11 +764,11 @@ public class ForgeHooksClient
IVertexBuilder ivertexbuilder;
if (fabulous)
{
ivertexbuilder = ItemRenderer.getEntityGlintVertexBuilder(bufferIn, rendertype, true, itemStackIn.hasEffect());
ivertexbuilder = ItemRenderer.getFoilBufferDirect(bufferIn, rendertype, true, itemStackIn.hasFoil());
} else {
ivertexbuilder = ItemRenderer.getBuffer(bufferIn, rendertype, true, itemStackIn.hasEffect());
ivertexbuilder = ItemRenderer.getFoilBuffer(bufferIn, rendertype, true, itemStackIn.hasFoil());
}
renderer.renderModel(layer, itemStackIn, combinedLightIn, combinedOverlayIn, matrixStackIn, ivertexbuilder);
renderer.renderModelLists(layer, itemStackIn, combinedLightIn, combinedOverlayIn, matrixStackIn, ivertexbuilder);
}
net.minecraftforge.client.ForgeHooksClient.setRenderLayer(null);
}
@@ -784,13 +784,13 @@ public class ForgeHooksClient
}
public static void renderPistonMovedBlocks(BlockPos pos, BlockState state, MatrixStack stack, IRenderTypeBuffer buffer, World world, boolean checkSides, int combinedOverlay, BlockRendererDispatcher blockRenderer) {
RenderType.getBlockRenderTypes().stream()
RenderType.chunkBufferLayers().stream()
.filter(t -> RenderTypeLookup.canRenderInLayer(state, t))
.forEach(rendertype ->
{
setRenderLayer(rendertype);
IVertexBuilder ivertexbuilder = buffer.getBuffer(rendertype == RenderType.getTranslucent() ? RenderType.getTranslucentMovingBlock() : rendertype);
blockRenderer.getBlockModelRenderer().renderModel(world, blockRenderer.getModelForState(state), state, pos, stack, ivertexbuilder, checkSides, new Random(), state.getPositionRandom(pos), combinedOverlay);
IVertexBuilder ivertexbuilder = buffer.getBuffer(rendertype == RenderType.translucent() ? RenderType.translucentMovingBlock() : rendertype);
blockRenderer.getModelRenderer().tesselateBlock(world, blockRenderer.getBlockModel(state), state, pos, stack, ivertexbuilder, checkSides, new Random(), state.getSeed(pos), combinedOverlay);
});
setRenderLayer(null);
}
@@ -812,7 +812,7 @@ public class ForgeHooksClient
public static Optional<BiomeGeneratorTypeScreens> getWorldTypeFromGenerator(DimensionGeneratorSettings dimensionGeneratorSettings)
{
return BiomeGeneratorTypeScreens.func_239079_a_(dimensionGeneratorSettings);
return BiomeGeneratorTypeScreens.of(dimensionGeneratorSettings);
}
public static Optional<BiomeGeneratorTypeScreens> getDefaultWorldType()
@@ -29,16 +29,19 @@ import net.minecraftforge.common.util.NonNullLazy;
import net.minecraftforge.common.util.NonNullSupplier;
import org.lwjgl.opengl.GL11;
import net.minecraft.client.renderer.RenderState.TextureState;
import net.minecraft.client.renderer.RenderType.State;
@SuppressWarnings("deprecation")
public enum ForgeRenderTypes
{
ITEM_LAYERED_SOLID(()-> getItemLayeredSolid(AtlasTexture.LOCATION_BLOCKS_TEXTURE)),
ITEM_LAYERED_CUTOUT(()-> getItemLayeredCutout(AtlasTexture.LOCATION_BLOCKS_TEXTURE)),
ITEM_LAYERED_CUTOUT_MIPPED(()-> getItemLayeredCutoutMipped(AtlasTexture.LOCATION_BLOCKS_TEXTURE)),
ITEM_LAYERED_TRANSLUCENT(()-> getItemLayeredTranslucent(AtlasTexture.LOCATION_BLOCKS_TEXTURE)),
ITEM_UNSORTED_TRANSLUCENT(()-> getUnsortedTranslucent(AtlasTexture.LOCATION_BLOCKS_TEXTURE)),
ITEM_UNLIT_TRANSLUCENT(()-> getUnlitTranslucent(AtlasTexture.LOCATION_BLOCKS_TEXTURE)),
ITEM_UNSORTED_UNLIT_TRANSLUCENT(()-> getUnlitTranslucent(AtlasTexture.LOCATION_BLOCKS_TEXTURE, false));
ITEM_LAYERED_SOLID(()-> getItemLayeredSolid(AtlasTexture.LOCATION_BLOCKS)),
ITEM_LAYERED_CUTOUT(()-> getItemLayeredCutout(AtlasTexture.LOCATION_BLOCKS)),
ITEM_LAYERED_CUTOUT_MIPPED(()-> getItemLayeredCutoutMipped(AtlasTexture.LOCATION_BLOCKS)),
ITEM_LAYERED_TRANSLUCENT(()-> getItemLayeredTranslucent(AtlasTexture.LOCATION_BLOCKS)),
ITEM_UNSORTED_TRANSLUCENT(()-> getUnsortedTranslucent(AtlasTexture.LOCATION_BLOCKS)),
ITEM_UNLIT_TRANSLUCENT(()-> getUnlitTranslucent(AtlasTexture.LOCATION_BLOCKS)),
ITEM_UNSORTED_UNLIT_TRANSLUCENT(()-> getUnlitTranslucent(AtlasTexture.LOCATION_BLOCKS, false));
/**
* @return A RenderType fit for multi-layer solid item rendering.
@@ -135,76 +138,76 @@ public enum ForgeRenderTypes
public static RenderType unsortedTranslucent(ResourceLocation textureLocation)
{
final boolean sortingEnabled = false;
State renderState = State.getBuilder()
.texture(new TextureState(textureLocation, false, false))
.transparency(TRANSLUCENT_TRANSPARENCY)
.diffuseLighting(DIFFUSE_LIGHTING_ENABLED)
.alpha(DEFAULT_ALPHA)
.cull(CULL_DISABLED)
.lightmap(LIGHTMAP_ENABLED)
.overlay(OVERLAY_ENABLED)
.build(true);
return makeType("forge_entity_unsorted_translucent", DefaultVertexFormats.ENTITY, GL11.GL_QUADS, 256, true, sortingEnabled, renderState);
State renderState = State.builder()
.setTextureState(new TextureState(textureLocation, false, false))
.setTransparencyState(TRANSLUCENT_TRANSPARENCY)
.setDiffuseLightingState(DIFFUSE_LIGHTING)
.setAlphaState(DEFAULT_ALPHA)
.setCullState(NO_CULL)
.setLightmapState(LIGHTMAP)
.setOverlayState(OVERLAY)
.createCompositeState(true);
return create("forge_entity_unsorted_translucent", DefaultVertexFormats.NEW_ENTITY, GL11.GL_QUADS, 256, true, sortingEnabled, renderState);
}
public static RenderType unlitTranslucent(ResourceLocation textureLocation, boolean sortingEnabled)
{
State renderState = State.getBuilder()
.texture(new TextureState(textureLocation, false, false))
.transparency(TRANSLUCENT_TRANSPARENCY)
.alpha(DEFAULT_ALPHA)
.cull(CULL_DISABLED)
.lightmap(LIGHTMAP_ENABLED)
.overlay(OVERLAY_ENABLED)
.build(true);
return makeType("forge_entity_unlit_translucent", DefaultVertexFormats.ENTITY, GL11.GL_QUADS, 256, true, sortingEnabled, renderState);
State renderState = State.builder()
.setTextureState(new TextureState(textureLocation, false, false))
.setTransparencyState(TRANSLUCENT_TRANSPARENCY)
.setAlphaState(DEFAULT_ALPHA)
.setCullState(NO_CULL)
.setLightmapState(LIGHTMAP)
.setOverlayState(OVERLAY)
.createCompositeState(true);
return create("forge_entity_unlit_translucent", DefaultVertexFormats.NEW_ENTITY, GL11.GL_QUADS, 256, true, sortingEnabled, renderState);
}
public static RenderType layeredItemSolid(ResourceLocation locationIn) {
RenderType.State rendertype$state = RenderType.State.getBuilder()
.texture(new RenderState.TextureState(locationIn, false, false))
.transparency(NO_TRANSPARENCY)
.diffuseLighting(DIFFUSE_LIGHTING_ENABLED)
.lightmap(LIGHTMAP_ENABLED)
.overlay(OVERLAY_ENABLED)
.build(true);
return makeType("forge_item_entity_solid", DefaultVertexFormats.ENTITY, 7, 256, true, false, rendertype$state);
RenderType.State rendertype$state = RenderType.State.builder()
.setTextureState(new RenderState.TextureState(locationIn, false, false))
.setTransparencyState(NO_TRANSPARENCY)
.setDiffuseLightingState(DIFFUSE_LIGHTING)
.setLightmapState(LIGHTMAP)
.setOverlayState(OVERLAY)
.createCompositeState(true);
return create("forge_item_entity_solid", DefaultVertexFormats.NEW_ENTITY, 7, 256, true, false, rendertype$state);
}
public static RenderType layeredItemCutout(ResourceLocation locationIn) {
RenderType.State rendertype$state = RenderType.State.getBuilder()
.texture(new RenderState.TextureState(locationIn, false, false))
.transparency(NO_TRANSPARENCY)
.diffuseLighting(DIFFUSE_LIGHTING_ENABLED)
.alpha(DEFAULT_ALPHA)
.lightmap(LIGHTMAP_ENABLED)
.overlay(OVERLAY_ENABLED)
.build(true);
return makeType("forge_item_entity_cutout", DefaultVertexFormats.ENTITY, 7, 256, true, false, rendertype$state);
RenderType.State rendertype$state = RenderType.State.builder()
.setTextureState(new RenderState.TextureState(locationIn, false, false))
.setTransparencyState(NO_TRANSPARENCY)
.setDiffuseLightingState(DIFFUSE_LIGHTING)
.setAlphaState(DEFAULT_ALPHA)
.setLightmapState(LIGHTMAP)
.setOverlayState(OVERLAY)
.createCompositeState(true);
return create("forge_item_entity_cutout", DefaultVertexFormats.NEW_ENTITY, 7, 256, true, false, rendertype$state);
}
public static RenderType layeredItemCutoutMipped(ResourceLocation locationIn) {
RenderType.State rendertype$state = RenderType.State.getBuilder()
.texture(new RenderState.TextureState(locationIn, false, true))
.transparency(NO_TRANSPARENCY)
.diffuseLighting(DIFFUSE_LIGHTING_ENABLED)
.alpha(DEFAULT_ALPHA)
.lightmap(LIGHTMAP_ENABLED)
.overlay(OVERLAY_ENABLED)
.build(true);
return makeType("forge_item_entity_cutout_mipped", DefaultVertexFormats.ENTITY, 7, 256, true, false, rendertype$state);
RenderType.State rendertype$state = RenderType.State.builder()
.setTextureState(new RenderState.TextureState(locationIn, false, true))
.setTransparencyState(NO_TRANSPARENCY)
.setDiffuseLightingState(DIFFUSE_LIGHTING)
.setAlphaState(DEFAULT_ALPHA)
.setLightmapState(LIGHTMAP)
.setOverlayState(OVERLAY)
.createCompositeState(true);
return create("forge_item_entity_cutout_mipped", DefaultVertexFormats.NEW_ENTITY, 7, 256, true, false, rendertype$state);
}
public static RenderType layeredItemTranslucent(ResourceLocation locationIn) {
RenderType.State rendertype$state = RenderType.State.getBuilder()
.texture(new RenderState.TextureState(locationIn, false, false))
.transparency(TRANSLUCENT_TRANSPARENCY)
.diffuseLighting(DIFFUSE_LIGHTING_ENABLED)
.alpha(DEFAULT_ALPHA)
.lightmap(LIGHTMAP_ENABLED)
.overlay(OVERLAY_ENABLED)
.build(true);
return makeType("forge_item_entity_translucent_cull", DefaultVertexFormats.ENTITY, 7, 256, true, true, rendertype$state);
RenderType.State rendertype$state = RenderType.State.builder()
.setTextureState(new RenderState.TextureState(locationIn, false, false))
.setTransparencyState(TRANSLUCENT_TRANSPARENCY)
.setDiffuseLightingState(DIFFUSE_LIGHTING)
.setAlphaState(DEFAULT_ALPHA)
.setLightmapState(LIGHTMAP)
.setOverlayState(OVERLAY)
.createCompositeState(true);
return create("forge_item_entity_translucent_cull", DefaultVertexFormats.NEW_ENTITY, 7, 256, true, true, rendertype$state);
}
}
}
@@ -57,14 +57,14 @@ public class ForgeWorldTypeScreens
ForgeWorldType def = ForgeWorldType.getDefaultWorldType();
if (def == null)
{
return BiomeGeneratorTypeScreens.field_239066_a_;
return BiomeGeneratorTypeScreens.NORMAL;
}
BiomeGeneratorTypeScreens gen = GENERATORS.get(def);
if (gen == null)
{
LOGGER.error("The default world type '{}' has not been added to the GUI. Was it registered too late?", def.getRegistryName());
return BiomeGeneratorTypeScreens.field_239066_a_;
return BiomeGeneratorTypeScreens.NORMAL;
}
return gen;
@@ -103,14 +103,14 @@ public class ForgeWorldTypeScreens
@Nonnull
@Override
public DimensionGeneratorSettings func_241220_a_(@Nonnull DynamicRegistries.Impl dynamicRegistries, long seed, boolean generateStructures, boolean bonusChest)
public DimensionGeneratorSettings create(@Nonnull DynamicRegistries.Impl dynamicRegistries, long seed, boolean generateStructures, boolean bonusChest)
{
return worldType.createSettings(dynamicRegistries, seed, generateStructures, bonusChest, "");
}
@Nonnull
@Override
protected ChunkGenerator func_241869_a(@Nonnull Registry<Biome> p_241869_1_, @Nonnull Registry<DimensionSettings> p_241869_2_, long p_241869_3_)
protected ChunkGenerator generator(@Nonnull Registry<Biome> p_241869_1_, @Nonnull Registry<DimensionSettings> p_241869_2_, long p_241869_3_)
{
return worldType.createChunkGenerator(p_241869_1_, p_241869_2_, p_241869_3_, "");
}
@@ -79,7 +79,7 @@ public class ItemModelMesherForge extends ItemModelMesher
if (location == null)
{
location = ModelBakery.MODEL_MISSING;
location = ModelBakery.MISSING_MODEL_LOCATION;
}
return location;
@@ -59,7 +59,7 @@ public class MinecraftForgeClient
*/
public static Locale getLocale()
{
return Minecraft.getInstance().getLanguageManager().getCurrentLanguage().getJavaLocale();
return Minecraft.getInstance().getLanguageManager().getSelected().getJavaLocale();
}
private static BitSet stencilBits = new BitSet(8);
@@ -108,7 +108,7 @@ public class MinecraftForgeClient
@Override
public Optional<ChunkRenderCache> load(Pair<World, BlockPos> key)
{
return Optional.ofNullable(ChunkRenderCache.generateCache(key.getLeft(), key.getRight().add(-1, -1, -1), key.getRight().add(16, 16, 16), 1));
return Optional.ofNullable(ChunkRenderCache.createIfNotEmpty(key.getLeft(), key.getRight().offset(-1, -1, -1), key.getRight().offset(16, 16, 16), 1));
}
});
@@ -25,6 +25,8 @@ import net.minecraft.client.renderer.FogRenderer.FogType;
import net.minecraft.client.renderer.GameRenderer;
import net.minecraftforge.eventbus.api.Cancelable;
import net.minecraftforge.eventbus.api.Event.HasResult;
/**
* Event that hooks into GameRenderer, allowing any feature to customize visual attributes
* the player sees.
@@ -34,7 +34,7 @@ public class FOVUpdateEvent extends Event
{
this.entity = entity;
this.fov = fov;
this.setNewfov(MathHelper.lerp(Minecraft.getInstance().gameSettings.fovScaleEffect, 1.0F, fov));
this.setNewfov(MathHelper.lerp(Minecraft.getInstance().options.fovEffectScale, 1.0F, fov));
}
public PlayerEntity getEntity()
@@ -47,7 +47,7 @@ public class RenderItemInFrameEvent extends Event
public RenderItemInFrameEvent(ItemFrameEntity itemFrame, ItemFrameRenderer renderItemFrame, MatrixStack matrix,
IRenderTypeBuffer buffers, int light)
{
item = itemFrame.getDisplayedItem();
item = itemFrame.getItem();
entityItemFrame = itemFrame;
renderer = renderItemFrame;
this.matrix = matrix;
@@ -38,7 +38,7 @@ public class PlaySoundEvent extends SoundEvent
{
super(manager);
this.sound = sound;
this.name = sound.getSoundLocation().getPath();
this.name = sound.getLocation().getPath();
this.setResultSound(sound);
}
@@ -46,7 +46,7 @@ public class SoundEvent extends net.minecraftforge.eventbus.api.Event
public SoundSourceEvent(SoundEngine manager, ISound sound, SoundSource source)
{
super(manager);
this.name = sound.getSoundLocation().getPath();
this.name = sound.getLocation().getPath();
this.sound = sound;
this.source = source;
}
@@ -55,7 +55,7 @@ public interface IForgeBakedModel
return getBakedModel().getQuads(state, side, rand);
}
default boolean isAmbientOcclusion(BlockState state) { return getBakedModel().isAmbientOcclusion(); }
default boolean isAmbientOcclusion(BlockState state) { return getBakedModel().useAmbientOcclusion(); }
/**
* Override to tell the new model loader that it shouldn't wrap this model
@@ -78,7 +78,7 @@ public interface IForgeBakedModel
default TextureAtlasSprite getParticleTexture(@Nonnull IModelData data)
{
return getBakedModel().getParticleTexture();
return getBakedModel().getParticleIcon();
}
/**
@@ -94,6 +94,6 @@ public interface IForgeBakedModel
*/
default List<Pair<IBakedModel, RenderType>> getLayerModels(ItemStack itemStack, boolean fabulous)
{
return Collections.singletonList(Pair.of(getBakedModel(), RenderTypeLookup.func_239219_a_(itemStack, fabulous)));
return Collections.singletonList(Pair.of(getBakedModel(), RenderTypeLookup.getRenderType(itemStack, fabulous)));
}
}
@@ -37,12 +37,12 @@ public interface IForgeKeybinding
*/
default boolean isActiveAndMatches(InputMappings.Input keyCode)
{
return keyCode != InputMappings.INPUT_INVALID && keyCode.equals(getKey()) && getKeyConflictContext().isActive() && getKeyModifier().isActive(getKeyConflictContext());
return keyCode != InputMappings.UNKNOWN && keyCode.equals(getKey()) && getKeyConflictContext().isActive() && getKeyModifier().isActive(getKeyConflictContext());
}
default void setToDefault()
{
setKeyModifierAndCode(getKeyModifierDefault(), getKeyBinding().getDefault());
setKeyModifierAndCode(getKeyModifierDefault(), getKeyBinding().getDefaultKey());
}
void setKeyConflictContext(IKeyConflictContext keyConflictContext);
@@ -40,6 +40,6 @@ public interface IForgeRenderChunk
*/
default ChunkRenderCache createRegionRenderCache(World world, BlockPos from, BlockPos to, int subtract)
{
return ChunkRenderCache.generateCache(world, from, to, subtract);
return ChunkRenderCache.createIfNotEmpty(world, from, to, subtract);
}
}
@@ -41,17 +41,17 @@ public interface IForgeTransformationMatrix
default void push(MatrixStack stack)
{
stack.push();
stack.pushPose();
Vector3f trans = getTransformaion().getTranslation();
stack.translate(trans.getX(), trans.getY(), trans.getZ());
stack.translate(trans.x(), trans.y(), trans.z());
stack.rotate(getTransformaion().getRotationLeft());
stack.mulPose(getTransformaion().getLeftRotation());
Vector3f scale = getTransformaion().getScale();
stack.scale(scale.getX(), scale.getY(), scale.getZ());
stack.scale(scale.x(), scale.y(), scale.z());
stack.rotate(getTransformaion().getRightRot());
stack.mulPose(getTransformaion().getRightRot());
}
@@ -60,7 +60,7 @@ public interface IForgeTransformationMatrix
if (getTransformaion().isIdentity()) return other;
if (other.isIdentity()) return getTransformaion();
Matrix4f m = getTransformaion().getMatrix();
m.mul(other.getMatrix());
m.multiply(other.getMatrix());
return new TransformationMatrix(m);
}
@@ -85,7 +85,7 @@ public interface IForgeTransformationMatrix
default Direction rotateTransform(Direction facing)
{
return Direction.rotateFace(getTransformaion().getMatrix(), facing);
return Direction.rotate(getTransformaion().getMatrix(), facing);
}
/**
@@ -114,11 +114,11 @@ public interface IForgeTransformationMatrix
if (transform.isIdentity()) return TransformationMatrix.identity();
Matrix4f ret = transform.getMatrix();
Matrix4f tmp = Matrix4f.makeTranslate(origin.getX(), origin.getY(), origin.getZ());
Matrix4f tmp = Matrix4f.createTranslateMatrix(origin.x(), origin.y(), origin.z());
ret.multiplyBackward(tmp);
tmp.setIdentity();
tmp.setTranslation(-origin.getX(), -origin.getY(), -origin.getZ());
ret.mul(tmp);
tmp.setTranslation(-origin.x(), -origin.y(), -origin.z());
ret.multiply(tmp);
return new TransformationMatrix(ret);
}
}
@@ -55,16 +55,16 @@ public interface IForgeVertexBuilder
// Copy of addQuad with alpha support
default void addVertexData(MatrixStack.Entry matrixEntry, BakedQuad bakedQuad, float[] baseBrightness, float red, float green, float blue, float alpha, int[] lightmapCoords, int overlayCoords, boolean readExistingColor) {
int[] aint = bakedQuad.getVertexData();
Vector3i faceNormal = bakedQuad.getFace().getDirectionVec();
int[] aint = bakedQuad.getVertices();
Vector3i faceNormal = bakedQuad.getDirection().getNormal();
Vector3f normal = new Vector3f((float)faceNormal.getX(), (float)faceNormal.getY(), (float)faceNormal.getZ());
Matrix4f matrix4f = matrixEntry.getMatrix();
normal.transform(matrixEntry.getNormal());
Matrix4f matrix4f = matrixEntry.pose();
normal.transform(matrixEntry.normal());
int intSize = DefaultVertexFormats.BLOCK.getIntegerSize();
int vertexCount = aint.length / intSize;
try (MemoryStack memorystack = MemoryStack.stackPush()) {
ByteBuffer bytebuffer = memorystack.malloc(DefaultVertexFormats.BLOCK.getSize());
ByteBuffer bytebuffer = memorystack.malloc(DefaultVertexFormats.BLOCK.getVertexSize());
IntBuffer intbuffer = bytebuffer.asIntBuffer();
for(int v = 0; v < vertexCount; ++v) {
@@ -98,8 +98,8 @@ public interface IForgeVertexBuilder
float f10 = bytebuffer.getFloat(20);
Vector4f pos = new Vector4f(f, f1, f2, 1.0F);
pos.transform(matrix4f);
applyBakedNormals(normal, bytebuffer, matrixEntry.getNormal());
((IVertexBuilder)this).addVertex(pos.getX(), pos.getY(), pos.getZ(), cr, cg, cb, ca, f9, f10, overlayCoords, lightmapCoord, normal.getX(), normal.getY(), normal.getZ());
applyBakedNormals(normal, bytebuffer, matrixEntry.normal());
((IVertexBuilder)this).vertex(pos.x(), pos.y(), pos.z(), cr, cg, cb, ca, f9, f10, overlayCoords, lightmapCoord, normal.x(), normal.y(), normal.z());
}
}
}
@@ -106,26 +106,26 @@ public class ForgeIngameGui extends IngameGui
}
@Override
public void renderIngameGui(MatrixStack mStack, float partialTicks)
public void render(MatrixStack mStack, float partialTicks)
{
this.scaledWidth = this.mc.getMainWindow().getScaledWidth();
this.scaledHeight = this.mc.getMainWindow().getScaledHeight();
eventParent = new RenderGameOverlayEvent(mStack, partialTicks, this.mc.getMainWindow());
renderHealthMount = mc.player.getRidingEntity() instanceof LivingEntity;
this.screenWidth = this.minecraft.getWindow().getGuiScaledWidth();
this.screenHeight = this.minecraft.getWindow().getGuiScaledHeight();
eventParent = new RenderGameOverlayEvent(mStack, partialTicks, this.minecraft.getWindow());
renderHealthMount = minecraft.player.getVehicle() instanceof LivingEntity;
renderFood = !renderHealthMount;
renderJumpBar = mc.player.isRidingHorse();
renderJumpBar = minecraft.player.isRidingJumpable();
right_height = 39;
left_height = 39;
if (pre(ALL, mStack)) return;
fontrenderer = mc.fontRenderer;
fontrenderer = minecraft.font;
//mc.entityRenderer.setupOverlayRendering();
RenderSystem.enableBlend();
if (renderVignette && Minecraft.isFancyGraphicsEnabled())
if (renderVignette && Minecraft.useFancyGraphics())
{
renderVignette(mc.getRenderViewEntity());
renderVignette(minecraft.getCameraEntity());
}
else
{
@@ -135,86 +135,86 @@ public class ForgeIngameGui extends IngameGui
if (renderHelmet) renderHelmet(partialTicks, mStack);
if (renderPortal && !mc.player.isPotionActive(Effects.NAUSEA))
if (renderPortal && !minecraft.player.hasEffect(Effects.CONFUSION))
{
renderPortal(partialTicks);
renderPortalOverlay(partialTicks);
}
if (this.mc.playerController.getCurrentGameType() == GameType.SPECTATOR)
if (this.minecraft.gameMode.getPlayerMode() == GameType.SPECTATOR)
{
if (renderSpectatorTooltip) spectatorGui.func_238528_a_(mStack, partialTicks);
if (renderSpectatorTooltip) spectatorGui.renderHotbar(mStack, partialTicks);
}
else if (!this.mc.gameSettings.hideGUI)
else if (!this.minecraft.options.hideGui)
{
if (renderHotbar) renderHotbar(partialTicks, mStack);
}
if (!this.mc.gameSettings.hideGUI) {
if (!this.minecraft.options.hideGui) {
RenderSystem.color4f(1.0F, 1.0F, 1.0F, 1.0F);
setBlitOffset(-90);
rand.setSeed((long)(ticks * 312871));
random.setSeed((long)(tickCount * 312871));
if (renderCrosshairs) func_238456_d_(mStack);
if (renderCrosshairs) renderCrosshair(mStack);
if (renderBossHealth) renderBossHealth(mStack);
RenderSystem.color4f(1.0F, 1.0F, 1.0F, 1.0F);
if (this.mc.playerController.shouldDrawHUD() && this.mc.getRenderViewEntity() instanceof PlayerEntity)
if (this.minecraft.gameMode.canHurtPlayer() && this.minecraft.getCameraEntity() instanceof PlayerEntity)
{
if (renderHealth) renderHealth(this.scaledWidth, this.scaledHeight, mStack);
if (renderArmor) renderArmor(mStack, this.scaledWidth, this.scaledHeight);
if (renderFood) renderFood(this.scaledWidth, this.scaledHeight, mStack);
if (renderHealthMount) renderHealthMount(this.scaledWidth, this.scaledHeight, mStack);
if (renderAir) renderAir(this.scaledWidth, this.scaledHeight, mStack);
if (renderHealth) renderHealth(this.screenWidth, this.screenHeight, mStack);
if (renderArmor) renderArmor(mStack, this.screenWidth, this.screenHeight);
if (renderFood) renderFood(this.screenWidth, this.screenHeight, mStack);
if (renderHealthMount) renderHealthMount(this.screenWidth, this.screenHeight, mStack);
if (renderAir) renderAir(this.screenWidth, this.screenHeight, mStack);
}
if (renderJumpBar)
{
renderHorseJumpBar(mStack, this.scaledWidth / 2 - 91);
renderJumpMeter(mStack, this.screenWidth / 2 - 91);
}
else if (renderExperiance)
{
renderExperience(this.scaledWidth / 2 - 91, mStack);
renderExperience(this.screenWidth / 2 - 91, mStack);
}
if (this.mc.gameSettings.heldItemTooltips && this.mc.playerController.getCurrentGameType() != GameType.SPECTATOR) {
this.func_238453_b_(mStack);
} else if (this.mc.player.isSpectator()) {
this.spectatorGui.func_238527_a_(mStack);
if (this.minecraft.options.heldItemTooltips && this.minecraft.gameMode.getPlayerMode() != GameType.SPECTATOR) {
this.renderSelectedItemName(mStack);
} else if (this.minecraft.player.isSpectator()) {
this.spectatorGui.renderTooltip(mStack);
}
}
renderSleepFade(this.scaledWidth, this.scaledHeight, mStack);
renderSleepFade(this.screenWidth, this.screenHeight, mStack);
renderHUDText(this.scaledWidth, this.scaledHeight, mStack);
renderHUDText(this.screenWidth, this.screenHeight, mStack);
renderFPSGraph(mStack);
renderPotionIcons(mStack);
if (!mc.gameSettings.hideGUI) {
renderRecordOverlay(this.scaledWidth, this.scaledHeight, partialTicks, mStack);
renderEffects(mStack);
if (!minecraft.options.hideGui) {
renderRecordOverlay(this.screenWidth, this.screenHeight, partialTicks, mStack);
renderSubtitles(mStack);
renderTitle(this.scaledWidth, this.scaledHeight, partialTicks, mStack);
renderTitle(this.screenWidth, this.screenHeight, partialTicks, mStack);
}
Scoreboard scoreboard = this.mc.world.getScoreboard();
Scoreboard scoreboard = this.minecraft.level.getScoreboard();
ScoreObjective objective = null;
ScorePlayerTeam scoreplayerteam = scoreboard.getPlayersTeam(mc.player.getScoreboardName());
ScorePlayerTeam scoreplayerteam = scoreboard.getPlayersTeam(minecraft.player.getScoreboardName());
if (scoreplayerteam != null)
{
int slot = scoreplayerteam.getColor().getColorIndex();
if (slot >= 0) objective = scoreboard.getObjectiveInDisplaySlot(3 + slot);
int slot = scoreplayerteam.getColor().getId();
if (slot >= 0) objective = scoreboard.getDisplayObjective(3 + slot);
}
ScoreObjective scoreobjective1 = objective != null ? objective : scoreboard.getObjectiveInDisplaySlot(1);
ScoreObjective scoreobjective1 = objective != null ? objective : scoreboard.getDisplayObjective(1);
if (renderObjective && scoreobjective1 != null)
{
this.func_238447_a_(mStack, scoreobjective1);
this.displayScoreboardSidebar(mStack, scoreobjective1);
}
RenderSystem.enableBlend();
RenderSystem.blendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, 1, 0);
RenderSystem.disableAlphaTest();
renderChat(this.scaledWidth, this.scaledHeight, mStack);
renderChat(this.screenWidth, this.screenHeight, mStack);
renderPlayerList(this.scaledWidth, this.scaledHeight, mStack);
renderPlayerList(this.screenWidth, this.screenHeight, mStack);
RenderSystem.color4f(1.0F, 1.0F, 1.0F, 1.0F);
RenderSystem.enableAlphaTest();
@@ -223,28 +223,28 @@ public class ForgeIngameGui extends IngameGui
}
@Override
protected void func_238456_d_(MatrixStack mStack)
protected void renderCrosshair(MatrixStack mStack)
{
if (pre(CROSSHAIRS, mStack)) return;
bind(AbstractGui.GUI_ICONS_LOCATION);
RenderSystem.enableBlend();
RenderSystem.enableAlphaTest();
super.func_238456_d_(mStack);
super.renderCrosshair(mStack);
post(CROSSHAIRS, mStack);
}
@Override
protected void renderPotionIcons(MatrixStack mStack)
protected void renderEffects(MatrixStack mStack)
{
if (pre(POTION_ICONS, mStack)) return;
super.renderPotionIcons(mStack);
super.renderEffects(mStack);
post(POTION_ICONS, mStack);
}
protected void renderSubtitles(MatrixStack mStack)
{
if (pre(SUBTITLES, mStack)) return;
this.overlaySubtitle.render(mStack);
this.subtitleOverlay.render(mStack);
post(SUBTITLES, mStack);
}
@@ -253,11 +253,11 @@ public class ForgeIngameGui extends IngameGui
if (pre(BOSSHEALTH, mStack)) return;
bind(AbstractGui.GUI_ICONS_LOCATION);
RenderSystem.defaultBlendFunc();
mc.getProfiler().startSection("bossHealth");
minecraft.getProfiler().push("bossHealth");
RenderSystem.enableBlend();
this.overlayBoss.func_238484_a_(mStack);
this.bossOverlay.render(mStack);
RenderSystem.disableBlend();
mc.getProfiler().endSection();
minecraft.getProfiler().pop();
post(BOSSHEALTH, mStack);
}
@@ -281,18 +281,18 @@ public class ForgeIngameGui extends IngameGui
{
if (pre(HELMET, mStack)) return;
ItemStack itemstack = this.mc.player.inventory.armorItemInSlot(3);
ItemStack itemstack = this.minecraft.player.inventory.getArmor(3);
if (this.mc.gameSettings.getPointOfView().func_243192_a() && !itemstack.isEmpty())
if (this.minecraft.options.getCameraType().isFirstPerson() && !itemstack.isEmpty())
{
Item item = itemstack.getItem();
if (item == Blocks.CARVED_PUMPKIN.asItem())
{
renderPumpkinOverlay();
renderPumpkin();
}
else
{
item.renderHelmetOverlay(itemstack, mc.player, this.scaledWidth, this.scaledHeight, partialTicks);
item.renderHelmetOverlay(itemstack, minecraft.player, this.screenWidth, this.screenHeight, partialTicks);
}
}
@@ -302,13 +302,13 @@ public class ForgeIngameGui extends IngameGui
protected void renderArmor(MatrixStack mStack, int width, int height)
{
if (pre(ARMOR, mStack)) return;
mc.getProfiler().startSection("armor");
minecraft.getProfiler().push("armor");
RenderSystem.enableBlend();
int left = width / 2 - 91;
int top = height - left_height;
int level = mc.player.getTotalArmorValue();
int level = minecraft.player.getArmorValue();
for (int i = 1; level > 0 && i < 20; i += 2)
{
if (i < level)
@@ -328,21 +328,21 @@ public class ForgeIngameGui extends IngameGui
left_height += 10;
RenderSystem.disableBlend();
mc.getProfiler().endSection();
minecraft.getProfiler().pop();
post(ARMOR, mStack);
}
@Override
protected void renderPortal(float partialTicks)
protected void renderPortalOverlay(float partialTicks)
{
MatrixStack mStack = new MatrixStack();
if (pre(PORTAL, mStack)) return;
float f1 = mc.player.prevTimeInPortal + (mc.player.timeInPortal - mc.player.prevTimeInPortal) * partialTicks;
float f1 = minecraft.player.oPortalTime + (minecraft.player.portalTime - minecraft.player.oPortalTime) * partialTicks;
if (f1 > 0.0F)
{
super.renderPortal(f1);
super.renderPortalOverlay(f1);
}
post(PORTAL, mStack);
@@ -353,9 +353,9 @@ public class ForgeIngameGui extends IngameGui
{
if (pre(HOTBAR, mStack)) return;
if (mc.playerController.getCurrentGameType() == GameType.SPECTATOR)
if (minecraft.gameMode.getPlayerMode() == GameType.SPECTATOR)
{
this.spectatorGui.func_238528_a_(mStack, partialTicks);
this.spectatorGui.renderHotbar(mStack, partialTicks);
}
else
{
@@ -368,14 +368,14 @@ public class ForgeIngameGui extends IngameGui
protected void renderAir(int width, int height, MatrixStack mStack)
{
if (pre(AIR, mStack)) return;
mc.getProfiler().startSection("air");
PlayerEntity player = (PlayerEntity)this.mc.getRenderViewEntity();
minecraft.getProfiler().push("air");
PlayerEntity player = (PlayerEntity)this.minecraft.getCameraEntity();
RenderSystem.enableBlend();
int left = width / 2 + 91;
int top = height - right_height;
int air = player.getAir();
if (player.areEyesInFluid(FluidTags.WATER) || air < 300)
int air = player.getAirSupply();
if (player.isEyeInFluid(FluidTags.WATER) || air < 300)
{
int full = MathHelper.ceil((double)(air - 2) * 10.0D / 300.0D);
int partial = MathHelper.ceil((double)air * 10.0D / 300.0D) - full;
@@ -388,7 +388,7 @@ public class ForgeIngameGui extends IngameGui
}
RenderSystem.disableBlend();
mc.getProfiler().endSection();
minecraft.getProfiler().pop();
post(AIR, mStack);
}
@@ -396,33 +396,33 @@ public class ForgeIngameGui extends IngameGui
{
bind(GUI_ICONS_LOCATION);
if (pre(HEALTH, mStack)) return;
mc.getProfiler().startSection("health");
minecraft.getProfiler().push("health");
RenderSystem.enableBlend();
PlayerEntity player = (PlayerEntity)this.mc.getRenderViewEntity();
PlayerEntity player = (PlayerEntity)this.minecraft.getCameraEntity();
int health = MathHelper.ceil(player.getHealth());
boolean highlight = healthUpdateCounter > (long)ticks && (healthUpdateCounter - (long)ticks) / 3L %2L == 1L;
boolean highlight = healthBlinkTime > (long)tickCount && (healthBlinkTime - (long)tickCount) / 3L %2L == 1L;
if (health < this.playerHealth && player.hurtResistantTime > 0)
if (health < this.lastHealth && player.invulnerableTime > 0)
{
this.lastSystemTime = Util.milliTime();
this.healthUpdateCounter = (long)(this.ticks + 20);
this.lastHealthTime = Util.getMillis();
this.healthBlinkTime = (long)(this.tickCount + 20);
}
else if (health > this.playerHealth && player.hurtResistantTime > 0)
else if (health > this.lastHealth && player.invulnerableTime > 0)
{
this.lastSystemTime = Util.milliTime();
this.healthUpdateCounter = (long)(this.ticks + 10);
this.lastHealthTime = Util.getMillis();
this.healthBlinkTime = (long)(this.tickCount + 10);
}
if (Util.milliTime() - this.lastSystemTime > 1000L)
if (Util.getMillis() - this.lastHealthTime > 1000L)
{
this.playerHealth = health;
this.lastPlayerHealth = health;
this.lastSystemTime = Util.milliTime();
this.lastHealth = health;
this.displayHealth = health;
this.lastHealthTime = Util.getMillis();
}
this.playerHealth = health;
int healthLast = this.lastPlayerHealth;
this.lastHealth = health;
int healthLast = this.displayHealth;
ModifiableAttributeInstance attrMaxHealth = player.getAttribute(Attributes.MAX_HEALTH);
float healthMax = (float)attrMaxHealth.getValue();
@@ -431,7 +431,7 @@ public class ForgeIngameGui extends IngameGui
int healthRows = MathHelper.ceil((healthMax + absorb) / 2.0F / 10.0F);
int rowHeight = Math.max(10 - (healthRows - 2), 3);
this.rand.setSeed((long)(ticks * 312871));
this.random.setSeed((long)(tickCount * 312871));
int left = width / 2 - 91;
int top = height - left_height;
@@ -439,16 +439,16 @@ public class ForgeIngameGui extends IngameGui
if (rowHeight != 10) left_height += 10 - rowHeight;
int regen = -1;
if (player.isPotionActive(Effects.REGENERATION))
if (player.hasEffect(Effects.REGENERATION))
{
regen = ticks % 25;
regen = tickCount % 25;
}
final int TOP = 9 * (mc.world.getWorldInfo().isHardcore() ? 5 : 0);
final int TOP = 9 * (minecraft.level.getLevelData().isHardcore() ? 5 : 0);
final int BACKGROUND = (highlight ? 25 : 16);
int MARGIN = 16;
if (player.isPotionActive(Effects.POISON)) MARGIN += 36;
else if (player.isPotionActive(Effects.WITHER)) MARGIN += 72;
if (player.hasEffect(Effects.POISON)) MARGIN += 36;
else if (player.hasEffect(Effects.WITHER)) MARGIN += 72;
float absorbRemaining = absorb;
for (int i = MathHelper.ceil((healthMax + absorb) / 2.0F) - 1; i >= 0; --i)
@@ -458,7 +458,7 @@ public class ForgeIngameGui extends IngameGui
int x = left + i % 10 * 8;
int y = top - row * rowHeight;
if (health <= 4) y += rand.nextInt(2);
if (health <= 4) y += random.nextInt(2);
if (i == regen) y -= 2;
blit(mStack, x, y, BACKGROUND, TOP, 9, 9);
@@ -494,23 +494,23 @@ public class ForgeIngameGui extends IngameGui
}
RenderSystem.disableBlend();
mc.getProfiler().endSection();
minecraft.getProfiler().pop();
post(HEALTH, mStack);
}
public void renderFood(int width, int height, MatrixStack mStack)
{
if (pre(FOOD, mStack)) return;
mc.getProfiler().startSection("food");
minecraft.getProfiler().push("food");
PlayerEntity player = (PlayerEntity)this.mc.getRenderViewEntity();
PlayerEntity player = (PlayerEntity)this.minecraft.getCameraEntity();
RenderSystem.enableBlend();
int left = width / 2 + 91;
int top = height - right_height;
right_height += 10;
boolean unused = false;// Unused flag in vanilla, seems to be part of a 'fade out' mechanic
FoodStats stats = mc.player.getFoodStats();
FoodStats stats = minecraft.player.getFoodData();
int level = stats.getFoodLevel();
for (int i = 0; i < 10; ++i)
@@ -521,16 +521,16 @@ public class ForgeIngameGui extends IngameGui
int icon = 16;
byte background = 0;
if (mc.player.isPotionActive(Effects.HUNGER))
if (minecraft.player.hasEffect(Effects.HUNGER))
{
icon += 36;
background = 13;
}
if (unused) background = 1; //Probably should be a += 1 but vanilla never uses this
if (player.getFoodStats().getSaturationLevel() <= 0.0F && ticks % (level * 3 + 1) == 0)
if (player.getFoodData().getSaturationLevel() <= 0.0F && tickCount % (level * 3 + 1) == 0)
{
y = top + (rand.nextInt(3) - 1);
y = top + (random.nextInt(3) - 1);
}
blit(mStack, x, y, 16 + background * 9, 27, 9, 9);
@@ -541,18 +541,18 @@ public class ForgeIngameGui extends IngameGui
blit(mStack, x, y, icon + 45, 27, 9, 9);
}
RenderSystem.disableBlend();
mc.getProfiler().endSection();
minecraft.getProfiler().pop();
post(FOOD, mStack);
}
protected void renderSleepFade(int width, int height, MatrixStack mStack)
{
if (mc.player.getSleepTimer() > 0)
if (minecraft.player.getSleepTimer() > 0)
{
mc.getProfiler().startSection("sleep");
minecraft.getProfiler().push("sleep");
RenderSystem.disableDepthTest();
RenderSystem.disableAlphaTest();
int sleepTime = mc.player.getSleepTimer();
int sleepTime = minecraft.player.getSleepTimer();
float opacity = (float)sleepTime / 100.0F;
if (opacity > 1.0F)
@@ -564,7 +564,7 @@ public class ForgeIngameGui extends IngameGui
fill(mStack, 0, 0, width, height, color);
RenderSystem.enableAlphaTest();
RenderSystem.enableDepthTest();
mc.getProfiler().endSection();
minecraft.getProfiler().pop();
}
}
@@ -575,9 +575,9 @@ public class ForgeIngameGui extends IngameGui
RenderSystem.color4f(1.0F, 1.0F, 1.0F, 1.0F);
RenderSystem.disableBlend();
if (mc.playerController.gameIsSurvivalOrAdventure())
if (minecraft.gameMode.hasExperience())
{
super.func_238454_b_(mStack, x);
super.renderExperienceBar(mStack, x);
}
RenderSystem.enableBlend();
RenderSystem.color4f(1.0F, 1.0F, 1.0F, 1.0F);
@@ -586,17 +586,17 @@ public class ForgeIngameGui extends IngameGui
}
@Override
public void renderHorseJumpBar(MatrixStack mStack, int x)
public void renderJumpMeter(MatrixStack mStack, int x)
{
bind(GUI_ICONS_LOCATION);
if (pre(JUMPBAR, mStack)) return;
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
RenderSystem.disableBlend();
super.renderHorseJumpBar(mStack, x);
super.renderJumpMeter(mStack, x);
RenderSystem.enableBlend();
mc.getProfiler().endSection();
minecraft.getProfiler().pop();
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
post(JUMPBAR, mStack);
@@ -604,25 +604,25 @@ public class ForgeIngameGui extends IngameGui
protected void renderHUDText(int width, int height, MatrixStack mStack)
{
mc.getProfiler().startSection("forgeHudText");
minecraft.getProfiler().push("forgeHudText");
RenderSystem.defaultBlendFunc();
ArrayList<String> listL = new ArrayList<String>();
ArrayList<String> listR = new ArrayList<String>();
if (mc.isDemo())
if (minecraft.isDemo())
{
long time = mc.world.getGameTime();
long time = minecraft.level.getGameTime();
if (time >= 120500L)
{
listR.add(I18n.format("demo.demoExpired"));
listR.add(I18n.get("demo.demoExpired"));
}
else
{
listR.add(I18n.format("demo.remainingTime", StringUtils.ticksToElapsedTime((int)(120500L - time))));
listR.add(I18n.get("demo.remainingTime", StringUtils.formatTickDuration((int)(120500L - time))));
}
}
if (this.mc.gameSettings.showDebugInfo && !pre(DEBUG, mStack))
if (this.minecraft.options.renderDebug && !pre(DEBUG, mStack))
{
debugOverlay.update();
listL.addAll(debugOverlay.getLeft());
@@ -637,30 +637,30 @@ public class ForgeIngameGui extends IngameGui
for (String msg : listL)
{
if (msg == null) continue;
fill(mStack, 1, top - 1, 2 + fontrenderer.getStringWidth(msg) + 1, top + fontrenderer.FONT_HEIGHT - 1, -1873784752);
fontrenderer.drawString(mStack, msg, 2, top, 14737632);
top += fontrenderer.FONT_HEIGHT;
fill(mStack, 1, top - 1, 2 + fontrenderer.width(msg) + 1, top + fontrenderer.lineHeight - 1, -1873784752);
fontrenderer.draw(mStack, msg, 2, top, 14737632);
top += fontrenderer.lineHeight;
}
top = 2;
for (String msg : listR)
{
if (msg == null) continue;
int w = fontrenderer.getStringWidth(msg);
int w = fontrenderer.width(msg);
int left = width - 2 - w;
fill(mStack, left - 1, top - 1, left + w + 1, top + fontrenderer.FONT_HEIGHT - 1, -1873784752);
fontrenderer.drawString(mStack, msg, left, top, 14737632);
top += fontrenderer.FONT_HEIGHT;
fill(mStack, left - 1, top - 1, left + w + 1, top + fontrenderer.lineHeight - 1, -1873784752);
fontrenderer.draw(mStack, msg, left, top, 14737632);
top += fontrenderer.lineHeight;
}
}
mc.getProfiler().endSection();
minecraft.getProfiler().pop();
post(TEXT, mStack);
}
protected void renderFPSGraph(MatrixStack mStack)
{
if (this.mc.gameSettings.showDebugInfo && this.mc.gameSettings.showLagometer && !pre(FPS_GRAPH, mStack))
if (this.minecraft.options.renderDebug && this.minecraft.options.renderFpsChart && !pre(FPS_GRAPH, mStack))
{
this.debugOverlay.render(mStack);
post(FPS_GRAPH, mStack);
@@ -671,7 +671,7 @@ public class ForgeIngameGui extends IngameGui
{
if (overlayMessageTime > 0)
{
mc.getProfiler().startSection("overlayMessage");
minecraft.getProfiler().push("overlayMessage");
float hue = (float)overlayMessageTime - partialTicks;
int opacity = (int)(hue * 255.0F / 20.0F);
if (opacity > 255) opacity = 255;
@@ -682,31 +682,31 @@ public class ForgeIngameGui extends IngameGui
RenderSystem.translatef((float)(width / 2), (float)(height - 68), 0.0F);
RenderSystem.enableBlend();
RenderSystem.defaultBlendFunc();
int color = (animateOverlayMessageColor ? MathHelper.hsvToRGB(hue / 50.0F, 0.7F, 0.6F) & WHITE : WHITE);
func_238448_a_(mStack, fontrenderer, -4, fontrenderer.getStringPropertyWidth(overlayMessage), 16777215 | (opacity << 24));
fontrenderer.func_238422_b_(mStack, overlayMessage.func_241878_f(), -fontrenderer.getStringPropertyWidth(overlayMessage) / 2, -4, color | (opacity << 24));
int color = (animateOverlayMessageColor ? MathHelper.hsvToRgb(hue / 50.0F, 0.7F, 0.6F) & WHITE : WHITE);
drawBackdrop(mStack, fontrenderer, -4, fontrenderer.width(overlayMessageString), 16777215 | (opacity << 24));
fontrenderer.draw(mStack, overlayMessageString.getVisualOrderText(), -fontrenderer.width(overlayMessageString) / 2, -4, color | (opacity << 24));
RenderSystem.disableBlend();
RenderSystem.popMatrix();
}
mc.getProfiler().endSection();
minecraft.getProfiler().pop();
}
}
protected void renderTitle(int width, int height, float partialTicks, MatrixStack mStack)
{
if (displayedTitle != null && titlesTimer > 0)
if (title != null && titleTime > 0)
{
mc.getProfiler().startSection("titleAndSubtitle");
float age = (float)this.titlesTimer - partialTicks;
minecraft.getProfiler().push("titleAndSubtitle");
float age = (float)this.titleTime - partialTicks;
int opacity = 255;
if (titlesTimer > titleFadeOut + titleDisplayTime)
if (titleTime > titleFadeOutTime + titleStayTime)
{
float f3 = (float)(titleFadeIn + titleDisplayTime + titleFadeOut) - age;
opacity = (int)(f3 * 255.0F / (float)titleFadeIn);
float f3 = (float)(titleFadeInTime + titleStayTime + titleFadeOutTime) - age;
opacity = (int)(f3 * 255.0F / (float)titleFadeInTime);
}
if (titlesTimer <= titleFadeOut) opacity = (int)(age * 255.0F / (float)this.titleFadeOut);
if (titleTime <= titleFadeOutTime) opacity = (int)(age * 255.0F / (float)this.titleFadeOutTime);
opacity = MathHelper.clamp(opacity, 0, 255);
@@ -719,62 +719,62 @@ public class ForgeIngameGui extends IngameGui
RenderSystem.pushMatrix();
RenderSystem.scalef(4.0F, 4.0F, 4.0F);
int l = opacity << 24 & -16777216;
this.getFontRenderer().func_238407_a_(mStack, this.displayedTitle.func_241878_f(), (float)(-this.getFontRenderer().getStringPropertyWidth(this.displayedTitle) / 2), -10.0F, 16777215 | l);
this.getFont().drawShadow(mStack, this.title.getVisualOrderText(), (float)(-this.getFont().width(this.title) / 2), -10.0F, 16777215 | l);
RenderSystem.popMatrix();
if (this.displayedSubTitle != null)
if (this.subtitle != null)
{
RenderSystem.pushMatrix();
RenderSystem.scalef(2.0F, 2.0F, 2.0F);
this.getFontRenderer().func_238407_a_(mStack, this.displayedSubTitle.func_241878_f(), (float)(-this.getFontRenderer().getStringPropertyWidth(this.displayedSubTitle) / 2), 5.0F, 16777215 | l);
this.getFont().drawShadow(mStack, this.subtitle.getVisualOrderText(), (float)(-this.getFont().width(this.subtitle) / 2), 5.0F, 16777215 | l);
RenderSystem.popMatrix();
}
RenderSystem.disableBlend();
RenderSystem.popMatrix();
}
this.mc.getProfiler().endSection();
this.minecraft.getProfiler().pop();
}
}
protected void renderChat(int width, int height, MatrixStack mStack)
{
mc.getProfiler().startSection("chat");
minecraft.getProfiler().push("chat");
RenderGameOverlayEvent.Chat event = new RenderGameOverlayEvent.Chat(mStack, eventParent, 0, height - 48);
if (MinecraftForge.EVENT_BUS.post(event)) return;
RenderSystem.pushMatrix();
RenderSystem.translatef((float) event.getPosX(), (float) event.getPosY(), 0.0F);
persistantChatGUI.func_238492_a_(mStack, ticks);
chat.render(mStack, tickCount);
RenderSystem.popMatrix();
post(CHAT, mStack);
mc.getProfiler().endSection();
minecraft.getProfiler().pop();
}
protected void renderPlayerList(int width, int height, MatrixStack mStack)
{
ScoreObjective scoreobjective = this.mc.world.getScoreboard().getObjectiveInDisplaySlot(0);
ClientPlayNetHandler handler = mc.player.connection;
ScoreObjective scoreobjective = this.minecraft.level.getScoreboard().getDisplayObjective(0);
ClientPlayNetHandler handler = minecraft.player.connection;
if (mc.gameSettings.keyBindPlayerList.isKeyDown() && (!mc.isIntegratedServerRunning() || handler.getPlayerInfoMap().size() > 1 || scoreobjective != null))
if (minecraft.options.keyPlayerList.isDown() && (!minecraft.isLocalServer() || handler.getOnlinePlayers().size() > 1 || scoreobjective != null))
{
this.overlayPlayerList.setVisible(true);
this.tabList.setVisible(true);
if (pre(PLAYER_LIST, mStack)) return;
this.overlayPlayerList.func_238523_a_(mStack, width, this.mc.world.getScoreboard(), scoreobjective);
this.tabList.render(mStack, width, this.minecraft.level.getScoreboard(), scoreobjective);
post(PLAYER_LIST, mStack);
}
else
{
this.overlayPlayerList.setVisible(false);
this.tabList.setVisible(false);
}
}
protected void renderHealthMount(int width, int height, MatrixStack mStack)
{
PlayerEntity player = (PlayerEntity)mc.getRenderViewEntity();
Entity tmp = player.getRidingEntity();
PlayerEntity player = (PlayerEntity)minecraft.getCameraEntity();
Entity tmp = player.getVehicle();
if (!(tmp instanceof LivingEntity)) return;
bind(GUI_ICONS_LOCATION);
@@ -784,7 +784,7 @@ public class ForgeIngameGui extends IngameGui
boolean unused = false;
int left_align = width / 2 + 91;
mc.getProfiler().endStartSection("mountHealth");
minecraft.getProfiler().popPush("mountHealth");
RenderSystem.enableBlend();
LivingEntity mount = (LivingEntity)tmp;
int health = (int)Math.ceil((double)mount.getHealth());
@@ -833,7 +833,7 @@ public class ForgeIngameGui extends IngameGui
}
private void bind(ResourceLocation res)
{
mc.getTextureManager().bindTexture(res);
minecraft.getTextureManager().bind(res);
}
private class GuiOverlayDebugForge extends DebugOverlayGui
@@ -846,20 +846,20 @@ public class ForgeIngameGui extends IngameGui
}
public void update()
{
Entity entity = this.mc.getRenderViewEntity();
this.rayTraceBlock = entity.pick(rayTraceDistance, 0.0F, false);
this.rayTraceFluid = entity.pick(rayTraceDistance, 0.0F, true);
Entity entity = this.mc.getCameraEntity();
this.block = entity.pick(rayTraceDistance, 0.0F, false);
this.liquid = entity.pick(rayTraceDistance, 0.0F, true);
}
@Override protected void renderDebugInfoLeft(MatrixStack mStack){}
@Override protected void renderDebugInfoRight(MatrixStack mStack){}
@Override protected void drawGameInformation(MatrixStack mStack){}
@Override protected void drawSystemInformation(MatrixStack mStack){}
private List<String> getLeft()
{
List<String> ret = this.getDebugInfoLeft();
List<String> ret = this.getGameInformation();
ret.add("");
ret.add("Debug: Pie [shift]: " + (this.mc.gameSettings.showDebugProfilerChart ? "visible" : "hidden") + " FPS [alt]: " + (this.mc.gameSettings.showLagometer ? "visible" : "hidden"));
ret.add("Debug: Pie [shift]: " + (this.mc.options.renderDebugCharts ? "visible" : "hidden") + " FPS [alt]: " + (this.mc.options.renderFpsChart ? "visible" : "hidden"));
ret.add("For help: press F3 + Q");
return ret;
}
private List<String> getRight(){ return this.getDebugInfoRight(); }
private List<String> getRight(){ return this.getSystemInformation(); }
}
}
@@ -73,13 +73,13 @@ public class NotificationModUpdateScreen extends Screen
return;
}
Minecraft.getInstance().getTextureManager().bindTexture(VERSION_CHECK_ICONS);
Minecraft.getInstance().getTextureManager().bind(VERSION_CHECK_ICONS);
RenderSystem.color4f(1, 1, 1, 1);
int x = modButton.x;
int y = modButton.y;
int w = modButton.getWidth();
int h = modButton.getHeightRealms();
int h = modButton.getHeight();
blit(mStack, x + w - (h / 2 + 4), y + (h / 2 - 4), showNotification.getSheetOffset() * 8, (showNotification.isAnimated() && ((System.currentTimeMillis() / 800 & 1) == 1)) ? 8 : 0, 8, 8, 64, 16);
}
@@ -189,14 +189,14 @@ public abstract class ScrollPanel extends FocusableGui implements IRenderable
this.drawBackground();
Tessellator tess = Tessellator.getInstance();
BufferBuilder worldr = tess.getBuffer();
BufferBuilder worldr = tess.getBuilder();
double scale = client.getMainWindow().getGuiScaleFactor();
double scale = client.getWindow().getGuiScale();
GL11.glEnable(GL11.GL_SCISSOR_TEST);
GL11.glScissor((int)(left * scale), (int)(client.getMainWindow().getFramebufferHeight() - (bottom * scale)),
GL11.glScissor((int)(left * scale), (int)(client.getWindow().getHeight() - (bottom * scale)),
(int)(width * scale), (int)(height * scale));
if (this.client.world != null)
if (this.client.level != null)
{
this.drawGradientRect(matrix, this.left, this.top, this.right, this.bottom, 0xC0101010, 0xD0101010);
}
@@ -204,15 +204,15 @@ public abstract class ScrollPanel extends FocusableGui implements IRenderable
{
RenderSystem.disableLighting();
RenderSystem.disableFog();
this.client.getTextureManager().bindTexture(AbstractGui.BACKGROUND_LOCATION);
this.client.getTextureManager().bind(AbstractGui.BACKGROUND_LOCATION);
RenderSystem.color4f(1.0F, 1.0F, 1.0F, 1.0F);
final float texScale = 32.0F;
worldr.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX_COLOR);
worldr.pos(this.left, this.bottom, 0.0D).tex(this.left / texScale, (this.bottom + (int)this.scrollDistance) / texScale).color(0x20, 0x20, 0x20, 0xFF).endVertex();
worldr.pos(this.right, this.bottom, 0.0D).tex(this.right / texScale, (this.bottom + (int)this.scrollDistance) / texScale).color(0x20, 0x20, 0x20, 0xFF).endVertex();
worldr.pos(this.right, this.top, 0.0D).tex(this.right / texScale, (this.top + (int)this.scrollDistance) / texScale).color(0x20, 0x20, 0x20, 0xFF).endVertex();
worldr.pos(this.left, this.top, 0.0D).tex(this.left / texScale, (this.top + (int)this.scrollDistance) / texScale).color(0x20, 0x20, 0x20, 0xFF).endVertex();
tess.draw();
worldr.vertex(this.left, this.bottom, 0.0D).uv(this.left / texScale, (this.bottom + (int)this.scrollDistance) / texScale).color(0x20, 0x20, 0x20, 0xFF).endVertex();
worldr.vertex(this.right, this.bottom, 0.0D).uv(this.right / texScale, (this.bottom + (int)this.scrollDistance) / texScale).color(0x20, 0x20, 0x20, 0xFF).endVertex();
worldr.vertex(this.right, this.top, 0.0D).uv(this.right / texScale, (this.top + (int)this.scrollDistance) / texScale).color(0x20, 0x20, 0x20, 0xFF).endVertex();
worldr.vertex(this.left, this.top, 0.0D).uv(this.left / texScale, (this.top + (int)this.scrollDistance) / texScale).color(0x20, 0x20, 0x20, 0xFF).endVertex();
tess.end();
}
int baseY = this.top + border - (int)this.scrollDistance;
@@ -233,23 +233,23 @@ public abstract class ScrollPanel extends FocusableGui implements IRenderable
RenderSystem.disableTexture();
worldr.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX_COLOR);
worldr.pos(barLeft, this.bottom, 0.0D).tex(0.0F, 1.0F).color(0x00, 0x00, 0x00, 0xFF).endVertex();
worldr.pos(barLeft + barWidth, this.bottom, 0.0D).tex(1.0F, 1.0F).color(0x00, 0x00, 0x00, 0xFF).endVertex();
worldr.pos(barLeft + barWidth, this.top, 0.0D).tex(1.0F, 0.0F).color(0x00, 0x00, 0x00, 0xFF).endVertex();
worldr.pos(barLeft, this.top, 0.0D).tex(0.0F, 0.0F).color(0x00, 0x00, 0x00, 0xFF).endVertex();
tess.draw();
worldr.vertex(barLeft, this.bottom, 0.0D).uv(0.0F, 1.0F).color(0x00, 0x00, 0x00, 0xFF).endVertex();
worldr.vertex(barLeft + barWidth, this.bottom, 0.0D).uv(1.0F, 1.0F).color(0x00, 0x00, 0x00, 0xFF).endVertex();
worldr.vertex(barLeft + barWidth, this.top, 0.0D).uv(1.0F, 0.0F).color(0x00, 0x00, 0x00, 0xFF).endVertex();
worldr.vertex(barLeft, this.top, 0.0D).uv(0.0F, 0.0F).color(0x00, 0x00, 0x00, 0xFF).endVertex();
tess.end();
worldr.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX_COLOR);
worldr.pos(barLeft, barTop + barHeight, 0.0D).tex(0.0F, 1.0F).color(0x80, 0x80, 0x80, 0xFF).endVertex();
worldr.pos(barLeft + barWidth, barTop + barHeight, 0.0D).tex(1.0F, 1.0F).color(0x80, 0x80, 0x80, 0xFF).endVertex();
worldr.pos(barLeft + barWidth, barTop, 0.0D).tex(1.0F, 0.0F).color(0x80, 0x80, 0x80, 0xFF).endVertex();
worldr.pos(barLeft, barTop, 0.0D).tex(0.0F, 0.0F).color(0x80, 0x80, 0x80, 0xFF).endVertex();
tess.draw();
worldr.vertex(barLeft, barTop + barHeight, 0.0D).uv(0.0F, 1.0F).color(0x80, 0x80, 0x80, 0xFF).endVertex();
worldr.vertex(barLeft + barWidth, barTop + barHeight, 0.0D).uv(1.0F, 1.0F).color(0x80, 0x80, 0x80, 0xFF).endVertex();
worldr.vertex(barLeft + barWidth, barTop, 0.0D).uv(1.0F, 0.0F).color(0x80, 0x80, 0x80, 0xFF).endVertex();
worldr.vertex(barLeft, barTop, 0.0D).uv(0.0F, 0.0F).color(0x80, 0x80, 0x80, 0xFF).endVertex();
tess.end();
worldr.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX_COLOR);
worldr.pos(barLeft, barTop + barHeight - 1, 0.0D).tex(0.0F, 1.0F).color(0xC0, 0xC0, 0xC0, 0xFF).endVertex();
worldr.pos(barLeft + barWidth - 1, barTop + barHeight - 1, 0.0D).tex(1.0F, 1.0F).color(0xC0, 0xC0, 0xC0, 0xFF).endVertex();
worldr.pos(barLeft + barWidth - 1, barTop, 0.0D).tex(1.0F, 0.0F).color(0xC0, 0xC0, 0xC0, 0xFF).endVertex();
worldr.pos(barLeft, barTop, 0.0D).tex(0.0F, 0.0F).color(0xC0, 0xC0, 0xC0, 0xFF).endVertex();
tess.draw();
worldr.vertex(barLeft, barTop + barHeight - 1, 0.0D).uv(0.0F, 1.0F).color(0xC0, 0xC0, 0xC0, 0xFF).endVertex();
worldr.vertex(barLeft + barWidth - 1, barTop + barHeight - 1, 0.0D).uv(1.0F, 1.0F).color(0xC0, 0xC0, 0xC0, 0xFF).endVertex();
worldr.vertex(barLeft + barWidth - 1, barTop, 0.0D).uv(1.0F, 0.0F).color(0xC0, 0xC0, 0xC0, 0xFF).endVertex();
worldr.vertex(barLeft, barTop, 0.0D).uv(0.0F, 0.0F).color(0xC0, 0xC0, 0xC0, 0xFF).endVertex();
tess.end();
}
RenderSystem.enableTexture();
@@ -261,11 +261,11 @@ public abstract class ScrollPanel extends FocusableGui implements IRenderable
protected void drawGradientRect(MatrixStack mStack, int left, int top, int right, int bottom, int color1, int color2)
{
GuiUtils.drawGradientRect(mStack.getLast().getMatrix(), 0, left, top, right, bottom, color1, color2);
GuiUtils.drawGradientRect(mStack.last().pose(), 0, left, top, right, bottom, color1, color2);
}
@Override
public List<? extends IGuiEventListener> getEventListeners()
public List<? extends IGuiEventListener> children()
{
return Collections.emptyList();
}
@@ -61,11 +61,11 @@ public class BakedItemModel implements IBakedModel
return guiTransform == null || guiTransform.isIdentity();
}
@Override public boolean isAmbientOcclusion() { return true; }
@Override public boolean useAmbientOcclusion() { return true; }
@Override public boolean isGui3d() { return false; }
@Override public boolean isSideLit() { return isSideLit; }
@Override public boolean isBuiltInRenderer() { return false; }
@Override public TextureAtlasSprite getParticleTexture() { return particle; }
@Override public boolean usesBlockLight() { return isSideLit; }
@Override public boolean isCustomRenderer() { return false; }
@Override public TextureAtlasSprite getParticleIcon() { return particle; }
@Override public ItemOverrideList getOverrides() { return overrides; }
@Override
@@ -98,7 +98,7 @@ public class BakedItemModel implements IBakedModel
ImmutableList.Builder<BakedQuad> builder = ImmutableList.builder();
for (BakedQuad quad : originalModel.quads)
{
if (quad.getFace() == Direction.SOUTH)
if (quad.getDirection() == Direction.SOUTH)
{
builder.add(quad);
}
@@ -52,9 +52,9 @@ public abstract class BakedModelWrapper<T extends IBakedModel> implements IBaked
}
@Override
public boolean isAmbientOcclusion()
public boolean useAmbientOcclusion()
{
return originalModel.isAmbientOcclusion();
return originalModel.useAmbientOcclusion();
}
@Override
@@ -70,27 +70,27 @@ public abstract class BakedModelWrapper<T extends IBakedModel> implements IBaked
}
@Override
public boolean isSideLit()
public boolean usesBlockLight()
{
return originalModel.isSideLit();
return originalModel.usesBlockLight();
}
@Override
public boolean isBuiltInRenderer()
public boolean isCustomRenderer()
{
return originalModel.isBuiltInRenderer();
return originalModel.isCustomRenderer();
}
@Override
public TextureAtlasSprite getParticleTexture()
public TextureAtlasSprite getParticleIcon()
{
return originalModel.getParticleTexture();
return originalModel.getParticleIcon();
}
@Override
public ItemCameraTransforms getItemCameraTransforms()
public ItemCameraTransforms getTransforms()
{
return originalModel.getItemCameraTransforms();
return originalModel.getTransforms();
}
@Override
@@ -95,13 +95,13 @@ public class BlockModelConfiguration implements IModelConfiguration
@Override
public boolean isTexturePresent(String name)
{
return owner.isTexturePresent(name);
return owner.hasTexture(name);
}
@Override
public RenderMaterial resolveTexture(String name)
{
return owner.resolveTextureName(name);
return owner.getMaterial(name);
}
@Override
@@ -112,19 +112,19 @@ public class BlockModelConfiguration implements IModelConfiguration
@Override
public boolean isSideLit()
{
return owner.getGuiLight().isSideLit();
return owner.getGuiLight().lightLikeBlock();
}
@Override
public boolean useSmoothLighting()
{
return owner.isAmbientOcclusion();
return owner.hasAmbientOcclusion();
}
@Override
public ItemCameraTransforms getCameraTransforms()
{
return owner.getAllTransforms();
return owner.getTransforms();
}
@Override
@@ -88,7 +88,7 @@ public class CompositeModel implements IDynamicBakedModel
}
@Override
public boolean isAmbientOcclusion()
public boolean useAmbientOcclusion()
{
return isAmbientOcclusion;
}
@@ -100,19 +100,19 @@ public class CompositeModel implements IDynamicBakedModel
}
@Override
public boolean isSideLit()
public boolean usesBlockLight()
{
return isSideLit;
}
@Override
public boolean isBuiltInRenderer()
public boolean isCustomRenderer()
{
return false;
}
@Override
public TextureAtlasSprite getParticleTexture()
public TextureAtlasSprite getParticleIcon()
{
return particle;
}
@@ -168,14 +168,14 @@ public class CompositeModel implements IDynamicBakedModel
public IBakedModel bakeModel(ModelBakery bakery, Function<RenderMaterial, TextureAtlasSprite> spriteGetter, IModelTransform modelTransform, ResourceLocation modelLocation)
{
return model.bakeModel(bakery, spriteGetter, new ModelTransformComposition(this.modelTransform, modelTransform,
this.modelTransform.isUvLock() || modelTransform.isUvLock()), modelLocation);
return model.bake(bakery, spriteGetter, new ModelTransformComposition(this.modelTransform, modelTransform,
this.modelTransform.isUvLocked() || modelTransform.isUvLocked()), modelLocation);
}
@Override
public Collection<RenderMaterial> getTextures(IModelConfiguration owner, Function<ResourceLocation, IUnbakedModel> modelGetter, Set<Pair<String, String>> missingTextureErrors)
{
return model.getTextures(modelGetter, missingTextureErrors);
return model.getMaterials(modelGetter, missingTextureErrors);
}
}
@@ -118,7 +118,7 @@ public final class DynamicBucketModel implements IModelGeometry<DynamicBucketMod
if (flipGas && fluid != Fluids.EMPTY && fluid.getAttributes().isLighterThanAir())
{
modelTransform = new SimpleModelTransform(
modelTransform.getRotation().blockCornerToCenter().composeVanilla(
modelTransform.getRotation().blockCornerToCenter().compose(
new TransformationMatrix(null, new Quaternion(0, 0, 1, 0), null, null)).blockCenterToCorner());
}
@@ -259,9 +259,9 @@ public final class DynamicBucketModel implements IModelGeometry<DynamicBucketMod
}
@Override
public IBakedModel getOverrideModel(IBakedModel originalModel, ItemStack stack, @Nullable ClientWorld world, @Nullable LivingEntity entity)
public IBakedModel resolve(IBakedModel originalModel, ItemStack stack, @Nullable ClientWorld world, @Nullable LivingEntity entity)
{
IBakedModel overriden = nested.getOverrideModel(originalModel, stack, world, entity);
IBakedModel overriden = nested.resolve(originalModel, stack, world, entity);
if (overriden != originalModel) return overriden;
return FluidUtil.getFluidContained(stack)
.map(fluidStack -> {
@@ -320,8 +320,8 @@ public final class FluidModel implements IModelGeometry<FluidModel>
// sides
for (int i = 0; i < 4; i++)
{
Direction side = Direction.byHorizontalIndex((5 - i) % 4); // [W, S, E, N]
boolean useOverlay = overlay.isPresent() && sideOverlays[side.getHorizontalIndex()];
Direction side = Direction.from2DDataValue((5 - i) % 4); // [W, S, E, N]
boolean useOverlay = overlay.isPresent() && sideOverlays[side.get2DDataValue()];
int si = i; // local var for lambda capture
VertexParameter sideX = j -> x[(si + x[j]) % 4];
@@ -377,8 +377,8 @@ public final class FluidModel implements IModelGeometry<FluidModel>
putVertex(
consumer, side, offset,
x.get(vertex), y.get(vertex), z.get(vertex),
texture.getInterpolatedU(u.get(vertex)),
texture.getInterpolatedV(v.get(vertex))
texture.getU(u.get(vertex)),
texture.getV(v.get(vertex))
);
}
@@ -394,9 +394,9 @@ public final class FluidModel implements IModelGeometry<FluidModel>
switch(elements.get(e).getUsage())
{
case POSITION:
float dx = offset ? side.getDirectionVec().getX() * eps : 0f;
float dy = offset ? side.getDirectionVec().getY() * eps : 0f;
float dz = offset ? side.getDirectionVec().getZ() * eps : 0f;
float dx = offset ? side.getNormal().getX() * eps : 0f;
float dy = offset ? side.getNormal().getY() * eps : 0f;
float dz = offset ? side.getNormal().getZ() * eps : 0f;
consumer.put(e, x - dx, y - dy, z - dz, 1f);
break;
case COLOR:
@@ -407,9 +407,9 @@ public final class FluidModel implements IModelGeometry<FluidModel>
consumer.put(e, r, g, b, a);
break;
case NORMAL:
float offX = (float) side.getXOffset();
float offY = (float) side.getYOffset();
float offZ = (float) side.getZOffset();
float offX = (float) side.getStepX();
float offY = (float) side.getStepY();
float offZ = (float) side.getStepZ();
consumer.put(e, offX, offY, offZ, 0f);
break;
case UV:
@@ -427,7 +427,7 @@ public final class FluidModel implements IModelGeometry<FluidModel>
}
@Override
public boolean isAmbientOcclusion()
public boolean useAmbientOcclusion()
{
return true;
}
@@ -439,19 +439,19 @@ public final class FluidModel implements IModelGeometry<FluidModel>
}
@Override
public boolean isSideLit()
public boolean usesBlockLight()
{
return false;
}
@Override
public boolean isBuiltInRenderer()
public boolean isCustomRenderer()
{
return false;
}
@Override
public TextureAtlasSprite getParticleTexture()
public TextureAtlasSprite getParticleIcon()
{
return still;
}
@@ -30,7 +30,7 @@ public interface IModelBuilder<T extends IModelBuilder<T>>
{
static IModelBuilder<?> of(IModelConfiguration owner, ItemOverrideList overrides, TextureAtlasSprite particle)
{
return new Simple(new SimpleBakedModel.Builder(owner, overrides).setTexture(particle));
return new Simple(new SimpleBakedModel.Builder(owner, overrides).particle(particle));
}
T addFaceQuad(Direction facing, BakedQuad quad);
@@ -49,14 +49,14 @@ public interface IModelBuilder<T extends IModelBuilder<T>>
@Override
public Simple addFaceQuad(Direction facing, BakedQuad quad)
{
builder.addFaceQuad(facing, quad);
builder.addCulledFace(facing, quad);
return this;
}
@Override
public Simple addGeneralQuad(BakedQuad quad)
{
builder.addGeneralQuad(quad);
builder.addUnculledFace(quad);
return this;
}
@@ -296,17 +296,17 @@ public final class ItemLayerModel implements IModelGeometry<ItemLayerModel>
// front
builder.add(buildQuad(transform, Direction.NORTH, sprite, tint, fullbright,
0, 0, 7.5f / 16f, sprite.getMinU(), sprite.getMaxV(),
0, 1, 7.5f / 16f, sprite.getMinU(), sprite.getMinV(),
1, 1, 7.5f / 16f, sprite.getMaxU(), sprite.getMinV(),
1, 0, 7.5f / 16f, sprite.getMaxU(), sprite.getMaxV()
0, 0, 7.5f / 16f, sprite.getU0(), sprite.getV1(),
0, 1, 7.5f / 16f, sprite.getU0(), sprite.getV0(),
1, 1, 7.5f / 16f, sprite.getU1(), sprite.getV0(),
1, 0, 7.5f / 16f, sprite.getU1(), sprite.getV1()
));
// back
builder.add(buildQuad(transform, Direction.SOUTH, sprite, tint, fullbright,
0, 0, 8.5f / 16f, sprite.getMinU(), sprite.getMaxV(),
1, 0, 8.5f / 16f, sprite.getMaxU(), sprite.getMaxV(),
1, 1, 8.5f / 16f, sprite.getMaxU(), sprite.getMinV(),
0, 1, 8.5f / 16f, sprite.getMinU(), sprite.getMinV()
0, 0, 8.5f / 16f, sprite.getU0(), sprite.getV1(),
1, 0, 8.5f / 16f, sprite.getU1(), sprite.getV1(),
1, 1, 8.5f / 16f, sprite.getU1(), sprite.getV0(),
0, 1, 8.5f / 16f, sprite.getU0(), sprite.getV0()
));
return builder.build();
@@ -381,8 +381,8 @@ public final class ItemLayerModel implements IModelGeometry<ItemLayerModel>
throw new IllegalArgumentException("can't handle z-oriented side");
}
float dx = side.getDirectionVec().getX() * eps / width;
float dy = side.getDirectionVec().getY() * eps / height;
float dx = side.getNormal().getX() * eps / width;
float dy = side.getNormal().getY() * eps / height;
float u0 = 16f * (x0 - dx);
float u1 = 16f * (x1 - dx);
@@ -391,10 +391,10 @@ public final class ItemLayerModel implements IModelGeometry<ItemLayerModel>
return buildQuad(
transform, remap(side), sprite, tint, fullbright,
x0, y0, z0, sprite.getInterpolatedU(u0), sprite.getInterpolatedV(v0),
x1, y1, z0, sprite.getInterpolatedU(u1), sprite.getInterpolatedV(v1),
x1, y1, z1, sprite.getInterpolatedU(u1), sprite.getInterpolatedV(v1),
x0, y0, z1, sprite.getInterpolatedU(u0), sprite.getInterpolatedV(v0)
x0, y0, z0, sprite.getU(u0), sprite.getV(v0),
x1, y1, z0, sprite.getU(u1), sprite.getV(v1),
x1, y1, z1, sprite.getU(u1), sprite.getV(v1),
x0, y0, z1, sprite.getU(u0), sprite.getV(v0)
);
}
@@ -445,9 +445,9 @@ public final class ItemLayerModel implements IModelGeometry<ItemLayerModel>
consumer.put(e, 1f, 1f, 1f, 1f);
break;
case NORMAL:
float offX = (float) side.getXOffset();
float offY = (float) side.getYOffset();
float offZ = (float) side.getZOffset();
float offX = (float) side.getStepX();
float offY = (float) side.getStepY();
float offZ = (float) side.getStepZ();
consumer.put(e, offX, offY, offZ, 0f);
break;
case UV:
@@ -484,7 +484,7 @@ public final class ItemLayerModel implements IModelGeometry<ItemLayerModel>
ImmutableSet.Builder<Integer> fullbrightLayers = ImmutableSet.builder();
if (modelContents.has("fullbright_layers"))
{
JsonArray arr = JSONUtils.getJsonArray(modelContents, "fullbright_layers");
JsonArray arr = JSONUtils.getAsJsonArray(modelContents, "fullbright_layers");
for(int i=0;i<arr.size();i++)
{
fullbrightLayers.add(arr.get(i).getAsInt());
@@ -76,7 +76,7 @@ public class ItemMultiLayerBakedModel implements IDynamicBakedModel
}
@Override
public boolean isAmbientOcclusion()
public boolean useAmbientOcclusion()
{
return smoothLighting;
}
@@ -88,19 +88,19 @@ public class ItemMultiLayerBakedModel implements IDynamicBakedModel
}
@Override
public boolean isSideLit()
public boolean usesBlockLight()
{
return sideLit;
}
@Override
public boolean isBuiltInRenderer()
public boolean isCustomRenderer()
{
return false;
}
@Override
public TextureAtlasSprite getParticleTexture()
public TextureAtlasSprite getParticleIcon()
{
return particle;
}
@@ -91,7 +91,7 @@ public final class ItemTextureQuadConverter
boolean sameRow = true;
for (int x = 0; x < w; x++)
{
if (template.isPixelTransparent(0, x, y) != template.isPixelTransparent(0, x, startY))
if (template.isTransparent(0, x, y) != template.isTransparent(0, x, startY))
{
sameRow = false;
break;
@@ -111,7 +111,7 @@ public final class ItemTextureQuadConverter
if (x < w)
{
// current pixel
boolean isVisible = !template.isPixelTransparent(0, x, startY);
boolean isVisible = !template.isTransparent(0, x, startY);
// no current quad but found a new one
if (startX < 0 && isVisible)
@@ -173,7 +173,7 @@ public final class ItemTextureQuadConverter
boolean sameColumn = true;
for (int y = 0; y < h; y++)
{
if (template.isPixelTransparent(0, x, y) != template.isPixelTransparent(0, startX, y))
if (template.isTransparent(0, x, y) != template.isTransparent(0, startX, y))
{
sameColumn = false;
break;
@@ -193,7 +193,7 @@ public final class ItemTextureQuadConverter
if (y < h)
{
// current pixel
boolean isVisible = !template.isPixelTransparent(0, startX, y);
boolean isVisible = !template.isTransparent(0, startX, y);
// no current quad but found a new one
if (startY < 0 && isVisible)
@@ -243,10 +243,10 @@ public final class ItemTextureQuadConverter
}
public static BakedQuad genQuad(TransformationMatrix transform, float x1, float y1, float x2, float y2, float z, TextureAtlasSprite sprite, Direction facing, int color, int tint, int luminosity)
{
float u1 = sprite.getInterpolatedU(x1);
float v1 = sprite.getInterpolatedV(y1);
float u2 = sprite.getInterpolatedU(x2);
float v2 = sprite.getInterpolatedV(y2);
float u1 = sprite.getU(x1);
float v1 = sprite.getV(y1);
float u2 = sprite.getU(x2);
float v2 = sprite.getV(y2);
x1 /= 16f;
y1 /= 16f;
@@ -311,9 +311,9 @@ public final class ItemTextureQuadConverter
consumer.put(e, r, g, b, a);
break;
case NORMAL:
float offX = (float) side.getXOffset();
float offY = (float) side.getYOffset();
float offZ = (float) side.getZOffset();
float offX = (float) side.getStepX();
float offY = (float) side.getStepY();
float offZ = (float) side.getStepZ();
consumer.put(e, offX, offY, offZ, 0f);
break;
case UV:
@@ -54,7 +54,7 @@ public class ModelDataManager
private static void cleanCaches(World world)
{
Preconditions.checkNotNull(world, "World must not be null");
Preconditions.checkArgument(world == Minecraft.getInstance().world, "Cannot use model data for a world other than the current client world");
Preconditions.checkArgument(world == Minecraft.getInstance().level, "Cannot use model data for a world other than the current client world");
if (world != currentWorld.get())
{
currentWorld = new WeakReference<>(world);
@@ -66,11 +66,11 @@ public class ModelDataManager
public static void requestModelDataRefresh(TileEntity te)
{
Preconditions.checkNotNull(te, "Tile entity must not be null");
World world = te.getWorld();
World world = te.getLevel();
cleanCaches(world);
needModelDataRefresh.computeIfAbsent(new ChunkPos(te.getPos()), $ -> Collections.synchronizedSet(new HashSet<>()))
.add(te.getPos());
needModelDataRefresh.computeIfAbsent(new ChunkPos(te.getBlockPos()), $ -> Collections.synchronizedSet(new HashSet<>()))
.add(te.getBlockPos());
}
private static void refreshModelData(World world, ChunkPos chunk)
@@ -83,7 +83,7 @@ public class ModelDataManager
Map<BlockPos, IModelData> data = modelDataCache.computeIfAbsent(chunk, $ -> new ConcurrentHashMap<>());
for (BlockPos pos : needUpdate)
{
TileEntity toUpdate = world.getTileEntity(pos);
TileEntity toUpdate = world.getBlockEntity(pos);
if (toUpdate != null && !toUpdate.isRemoved())
{
data.put(pos, toUpdate.getModelData());
@@ -99,7 +99,7 @@ public class ModelDataManager
@SubscribeEvent
public static void onChunkUnload(ChunkEvent.Unload event)
{
if (!event.getChunk().getWorldForge().isRemote()) return;
if (!event.getChunk().getWorldForge().isClientSide()) return;
ChunkPos chunk = event.getChunk().getPos();
needModelDataRefresh.remove(chunk);
@@ -113,7 +113,7 @@ public class ModelDataManager
public static Map<BlockPos, IModelData> getModelData(World world, ChunkPos pos)
{
Preconditions.checkArgument(world.isRemote, "Cannot request model data for server world");
Preconditions.checkArgument(world.isClientSide, "Cannot request model data for server world");
refreshModelData(world, pos);
return modelDataCache.getOrDefault(pos, Collections.emptyMap());
}
@@ -113,7 +113,7 @@ public final class ModelLoader extends ModelBakery
{
try
{
missingModel = getUnbakedModel(MODEL_MISSING);
missingModel = getModel(MISSING_MODEL_LOCATION);
}
catch(Exception e)
{
@@ -130,7 +130,7 @@ public final class ModelLoader extends ModelBakery
{
try
{
return getUnbakedModel(location);
return getModel(location);
}
catch(Exception e)
{
@@ -145,7 +145,7 @@ public final class ModelLoader extends ModelBakery
{
try
{
return getUnbakedModel(location);
return getModel(location);
}
catch(Exception e)
{
@@ -163,7 +163,7 @@ public final class ModelLoader extends ModelBakery
{
if (instance == null)
{
instance = new RenderMaterial(AtlasTexture.LOCATION_BLOCKS_TEXTURE, LOCATION).getSprite();
instance = new RenderMaterial(AtlasTexture.LOCATION_BLOCKS, LOCATION).sprite();
}
return instance;
}
@@ -230,7 +230,7 @@ public final class ModelLoader extends ModelBakery
*/
public void onPostBakeEvent(Map<ResourceLocation, IBakedModel> modelRegistry)
{
IBakedModel missingModel = modelRegistry.get(MODEL_MISSING);
IBakedModel missingModel = modelRegistry.get(MISSING_MODEL_LOCATION);
for(Map.Entry<ResourceLocation, Exception> entry : loadingExceptions.entrySet())
{
// ignoring pure ResourceLocation arguments, all things we care about pass ModelResourceLocation
@@ -265,7 +265,7 @@ public final class ModelLoader extends ModelBakery
*/
public static Function<RenderMaterial, TextureAtlasSprite> defaultTextureGetter()
{
return RenderMaterial::getSprite;
return RenderMaterial::sprite;
}
public static Function<ResourceLocation, IUnbakedModel> defaultModelGetter()
@@ -102,7 +102,7 @@ public class ModelLoaderRegistry
synchronized(loaders)
{
loaders.put(id, loader);
((IReloadableResourceManager) Minecraft.getInstance().getResourceManager()).addReloadListener(loader);
((IReloadableResourceManager) Minecraft.getInstance().getResourceManager()).registerReloadListener(loader);
}
}
@@ -133,7 +133,7 @@ public class ModelLoaderRegistry
return null;
}
ResourceLocation loader = new ResourceLocation(JSONUtils.getString(object,"loader"));
ResourceLocation loader = new ResourceLocation(JSONUtils.getAsString(object,"loader"));
return getModel(loader, deserializationContext, object);
}
@@ -178,13 +178,13 @@ public class ModelLoaderRegistry
@SuppressWarnings("deprecation")
public static RenderMaterial blockMaterial(String location)
{
return new RenderMaterial(AtlasTexture.LOCATION_BLOCKS_TEXTURE, new ResourceLocation(location));
return new RenderMaterial(AtlasTexture.LOCATION_BLOCKS, new ResourceLocation(location));
}
@SuppressWarnings("deprecation")
public static RenderMaterial blockMaterial(ResourceLocation location)
{
return new RenderMaterial(AtlasTexture.LOCATION_BLOCKS_TEXTURE, location);
return new RenderMaterial(AtlasTexture.LOCATION_BLOCKS, location);
}
@Nullable
@@ -264,15 +264,15 @@ public class ModelLoaderRegistry
IModelGeometry<?> customModel = blockModel.customData.getCustomGeometry();
IModelTransform customModelState = blockModel.customData.getCustomModelState();
if (customModelState != null)
modelTransform = new ModelTransformComposition(modelTransform, customModelState, modelTransform.isUvLock());
modelTransform = new ModelTransformComposition(modelTransform, customModelState, modelTransform.isUvLocked());
if (customModel != null)
model = customModel.bake(blockModel.customData, modelBakery, spriteGetter, modelTransform, blockModel.getOverrides(modelBakery, otherModel, spriteGetter), modelLocation);
else
{
// handle vanilla item models here, since vanilla has a shortcut for them
if (blockModel.getRootModel() == ModelBakery.MODEL_GENERATED) {
model = ITEM_MODEL_GENERATOR.makeItemModel(spriteGetter, blockModel).bakeModel(modelBakery, blockModel, spriteGetter, modelTransform, modelLocation, guiLight3d);
if (blockModel.getRootModel() == ModelBakery.GENERATION_MARKER) {
model = ITEM_MODEL_GENERATOR.generateBlockModel(spriteGetter, blockModel).bake(modelBakery, blockModel, spriteGetter, modelTransform, modelLocation, guiLight3d);
}
else
{
@@ -299,14 +299,14 @@ public class ModelLoaderRegistry
public void addQuads(IModelConfiguration owner, IModelBuilder<?> modelBuilder, ModelBakery bakery, Function<RenderMaterial, TextureAtlasSprite> spriteGetter, IModelTransform modelTransform, ResourceLocation modelLocation)
{
for(BlockPart blockpart : elements) {
for(Direction direction : blockpart.mapFaces.keySet()) {
BlockPartFace blockpartface = blockpart.mapFaces.get(direction);
for(Direction direction : blockpart.faces.keySet()) {
BlockPartFace blockpartface = blockpart.faces.get(direction);
TextureAtlasSprite textureatlassprite1 = spriteGetter.apply(owner.resolveTexture(blockpartface.texture));
if (blockpartface.cullFace == null) {
if (blockpartface.cullForDirection == null) {
modelBuilder.addGeneralQuad(BlockModel.makeBakedQuad(blockpart, blockpartface, textureatlassprite1, direction, modelTransform, modelLocation));
} else {
modelBuilder.addFaceQuad(
modelTransform.getRotation().rotateTransform(blockpartface.cullFace),
modelTransform.getRotation().rotateTransform(blockpartface.cullForDirection),
BlockModel.makeBakedQuad(blockpart, blockpartface, textureatlassprite1, direction, modelTransform, modelLocation));
}
}
@@ -319,7 +319,7 @@ public class ModelLoaderRegistry
Set<RenderMaterial> textures = Sets.newHashSet();
for(BlockPart part : elements) {
for(BlockPartFace face : part.mapFaces.values()) {
for(BlockPartFace face : part.faces.values()) {
RenderMaterial texture = owner.resolveTexture(face.texture);
if (Objects.equals(texture, MissingTextureSprite.getLocation().toString())) {
missingTextureErrors.add(Pair.of(face.texture, owner.getModelName()));
@@ -356,7 +356,7 @@ public class ModelLoaderRegistry
private List<BlockPart> getModelElements(JsonDeserializationContext deserializationContext, JsonObject object) {
List<BlockPart> list = Lists.newArrayList();
if (object.has("elements")) {
for(JsonElement jsonelement : JSONUtils.getJsonArray(object, "elements")) {
for(JsonElement jsonelement : JSONUtils.getAsJsonArray(object, "elements")) {
list.add(deserializationContext.deserialize(jsonelement, BlockPart.class));
}
}
@@ -398,7 +398,7 @@ public class ModelLoaderRegistry
if (jsonobject.has("visibility"))
{
JsonObject visibility = JSONUtils.getJsonObject(jsonobject, "visibility");
JsonObject visibility = JSONUtils.getAsJsonObject(jsonobject, "visibility");
for(Map.Entry<String, JsonElement> part : visibility.entrySet())
{
model.customData.visibilityData.setVisibilityState(part.getKey(), part.getValue().getAsBoolean());
@@ -45,7 +45,7 @@ public class ModelTransformComposition implements IModelTransform
}
@Override
public boolean isUvLock()
public boolean isUvLocked()
{
return uvLock;
}
@@ -79,7 +79,7 @@ public final class MultiLayerModel implements IModelGeometry<MultiLayerModel>
Set<RenderMaterial> materials = Sets.newHashSet();
materials.add(owner.resolveTexture("particle"));
for (Pair<RenderType, IUnbakedModel> m : models)
materials.addAll(m.getSecond().getTextures(modelGetter, missingTextureErrors));
materials.addAll(m.getSecond().getMaterials(modelGetter, missingTextureErrors));
return materials;
}
@@ -89,7 +89,7 @@ public final class MultiLayerModel implements IModelGeometry<MultiLayerModel>
ImmutableList.Builder<Pair<RenderType, IBakedModel>> builder = ImmutableList.builder();
for(Pair<RenderType, IUnbakedModel> entry : models)
{
builder.add(Pair.of(entry.getFirst(), entry.getSecond().bakeModel(bakery, spriteGetter, modelTransform, modelLocation)));
builder.add(Pair.of(entry.getFirst(), entry.getSecond().bake(bakery, spriteGetter, modelTransform, modelLocation)));
}
return builder.build();
}
@@ -102,7 +102,7 @@ public final class MultiLayerModel implements IModelGeometry<MultiLayerModel>
return new MultiLayerBakedModel(
owner.useSmoothLighting(), owner.isShadedInGui(), owner.isSideLit(),
spriteGetter.apply(owner.resolveTexture("particle")), overrides, convertRenderTypes,
missing.bakeModel(bakery, spriteGetter, modelTransform, modelLocation),
missing.bake(bakery, spriteGetter, modelTransform, modelLocation),
buildModels(models, modelTransform, bakery, spriteGetter, modelLocation),
PerspectiveMapWrapper.getTransforms(new ModelTransformComposition(owner.getCombinedTransform(), modelTransform))
);
@@ -164,7 +164,7 @@ public final class MultiLayerModel implements IModelGeometry<MultiLayerModel>
}
@Override
public boolean isAmbientOcclusion()
public boolean useAmbientOcclusion()
{
return ambientOcclusion;
}
@@ -182,19 +182,19 @@ public final class MultiLayerModel implements IModelGeometry<MultiLayerModel>
}
@Override
public boolean isSideLit()
public boolean usesBlockLight()
{
return isSideLit;
}
@Override
public boolean isBuiltInRenderer()
public boolean isCustomRenderer()
{
return false;
}
@Override
public TextureAtlasSprite getParticleTexture()
public TextureAtlasSprite getParticleIcon()
{
return particle;
}
@@ -231,21 +231,21 @@ public final class MultiLayerModel implements IModelGeometry<MultiLayerModel>
public static BiMap<RenderType, RenderType> ITEM_RENDER_TYPE_MAPPING = HashBiMap.create();
static {
ITEM_RENDER_TYPE_MAPPING.put(RenderType.getSolid(), ForgeRenderTypes.ITEM_LAYERED_SOLID.get());
ITEM_RENDER_TYPE_MAPPING.put(RenderType.getCutout(), ForgeRenderTypes.ITEM_LAYERED_CUTOUT.get());
ITEM_RENDER_TYPE_MAPPING.put(RenderType.getCutoutMipped(), ForgeRenderTypes.ITEM_LAYERED_CUTOUT_MIPPED.get());
ITEM_RENDER_TYPE_MAPPING.put(RenderType.getTranslucent(), ForgeRenderTypes.ITEM_LAYERED_TRANSLUCENT.get());
ITEM_RENDER_TYPE_MAPPING.put(RenderType.solid(), ForgeRenderTypes.ITEM_LAYERED_SOLID.get());
ITEM_RENDER_TYPE_MAPPING.put(RenderType.cutout(), ForgeRenderTypes.ITEM_LAYERED_CUTOUT.get());
ITEM_RENDER_TYPE_MAPPING.put(RenderType.cutoutMipped(), ForgeRenderTypes.ITEM_LAYERED_CUTOUT_MIPPED.get());
ITEM_RENDER_TYPE_MAPPING.put(RenderType.translucent(), ForgeRenderTypes.ITEM_LAYERED_TRANSLUCENT.get());
}
}
public static final class Loader implements IModelLoader<MultiLayerModel>
{
public static final ImmutableBiMap<String, RenderType> BLOCK_LAYERS = ImmutableBiMap.<String, RenderType>builder()
.put("solid", RenderType.getSolid())
.put("cutout", RenderType.getCutout())
.put("cutout_mipped", RenderType.getCutoutMipped())
.put("translucent", RenderType.getTranslucent())
.put("tripwire", RenderType.getTripwire())
.put("solid", RenderType.solid())
.put("cutout", RenderType.cutout())
.put("cutout_mipped", RenderType.cutoutMipped())
.put("translucent", RenderType.translucent())
.put("tripwire", RenderType.tripwire())
.build();
public static final Loader INSTANCE = new Loader();
@@ -262,16 +262,16 @@ public final class MultiLayerModel implements IModelGeometry<MultiLayerModel>
public MultiLayerModel read(JsonDeserializationContext deserializationContext, JsonObject modelContents)
{
ImmutableList.Builder<Pair<RenderType, IUnbakedModel>> builder = ImmutableList.builder();
JsonObject layersObject = JSONUtils.getJsonObject(modelContents, "layers");
JsonObject layersObject = JSONUtils.getAsJsonObject(modelContents, "layers");
for(Map.Entry<String, RenderType> layer : BLOCK_LAYERS.entrySet()) // block layers
{
String layerName = layer.getKey(); // mc overrides toString to return the ID for the layer
if(layersObject.has(layerName))
{
builder.add(Pair.of(layer.getValue(), deserializationContext.deserialize(JSONUtils.getJsonObject(layersObject, layerName), BlockModel.class)));
builder.add(Pair.of(layer.getValue(), deserializationContext.deserialize(JSONUtils.getAsJsonObject(layersObject, layerName), BlockModel.class)));
}
}
boolean convertRenderTypes = JSONUtils.getBoolean(modelContents, "convert_render_types", true);
boolean convertRenderTypes = JSONUtils.getAsBoolean(modelContents, "convert_render_types", true);
return new MultiLayerModel(builder.build(), convertRenderTypes);
}
}
@@ -78,7 +78,7 @@ public class PerspectiveMapWrapper implements IDynamicBakedModel
EnumMap<ItemCameraTransforms.TransformType, TransformationMatrix> map = new EnumMap<>(ItemCameraTransforms.TransformType.class);
for(ItemCameraTransforms.TransformType type : ItemCameraTransforms.TransformType.values())
{
if (transforms.hasCustomTransform(type))
if (transforms.hasTransform(type))
{
map.put(type, TransformationHelper.toTransformation(transforms.getTransform(type)));
}
@@ -97,7 +97,7 @@ public class PerspectiveMapWrapper implements IDynamicBakedModel
{
map.put(type, tr);
}
else if (transforms.hasCustomTransform(type))
else if (transforms.hasTransform(type))
{
map.put(type, TransformationHelper.toTransformation(transforms.getTransform(type)));
}
@@ -125,14 +125,14 @@ public class PerspectiveMapWrapper implements IDynamicBakedModel
return model;
}
@Override public boolean isAmbientOcclusion() { return parent.isAmbientOcclusion(); }
@Override public boolean useAmbientOcclusion() { return parent.useAmbientOcclusion(); }
@Override public boolean isAmbientOcclusion(BlockState state) { return parent.isAmbientOcclusion(state); }
@Override public boolean isGui3d() { return parent.isGui3d(); }
@Override public boolean isSideLit() { return parent.isSideLit(); }
@Override public boolean isBuiltInRenderer() { return parent.isBuiltInRenderer(); }
@Override public TextureAtlasSprite getParticleTexture() { return parent.getParticleTexture(); }
@Override public boolean usesBlockLight() { return parent.usesBlockLight(); }
@Override public boolean isCustomRenderer() { return parent.isCustomRenderer(); }
@Override public TextureAtlasSprite getParticleIcon() { return parent.getParticleIcon(); }
@SuppressWarnings("deprecation")
@Override public ItemCameraTransforms getItemCameraTransforms() { return parent.getItemCameraTransforms(); }
@Override public ItemCameraTransforms getTransforms() { return parent.getTransforms(); }
@Override public List<BakedQuad> getQuads(@Nullable BlockState state, @Nullable Direction side, Random rand, IModelData extraData)
{
return parent.getQuads(state, side, rand, extraData);
@@ -165,9 +165,9 @@ public class PerspectiveMapWrapper implements IDynamicBakedModel
@Nullable
@Override
public IBakedModel getOverrideModel(IBakedModel model, ItemStack stack, @Nullable ClientWorld worldIn, @Nullable LivingEntity entityIn)
public IBakedModel resolve(IBakedModel model, ItemStack stack, @Nullable ClientWorld worldIn, @Nullable LivingEntity entityIn)
{
model = parent.getOverrides().getOverrideModel(parent, stack, worldIn, entityIn);
model = parent.getOverrides().resolve(parent, stack, worldIn, entityIn);
return new PerspectiveMapWrapper(model, transforms);
}
@@ -46,7 +46,7 @@ public class QuadTransformer
private void processVertices(int[] inData, int[] outData)
{
int stride = DefaultVertexFormats.BLOCK.getSize();
int stride = DefaultVertexFormats.BLOCK.getVertexSize();
int count = (inData.length * 4) / stride;
for (int i=0;i<count;i++)
{
@@ -59,9 +59,9 @@ public class QuadTransformer
transform.transformPosition(pos);
pos.perspectiveDivide();
putAtByteOffset(outData, offset, Float.floatToRawIntBits(pos.getX()));
putAtByteOffset(outData,offset + 4, Float.floatToRawIntBits(pos.getY()));
putAtByteOffset(outData,offset + 8, Float.floatToRawIntBits(pos.getZ()));
putAtByteOffset(outData, offset, Float.floatToRawIntBits(pos.x()));
putAtByteOffset(outData,offset + 4, Float.floatToRawIntBits(pos.y()));
putAtByteOffset(outData,offset + 8, Float.floatToRawIntBits(pos.z()));
}
for (int i=0;i<count;i++)
@@ -138,7 +138,7 @@ public class QuadTransformer
throw new RuntimeException("Expected vertex format to have a POSITION attribute");
if (element.getType() != VertexFormatElement.Type.FLOAT)
throw new RuntimeException("Expected POSITION attribute to have data type FLOAT");
if (element.getSize() < 3)
if (element.getByteSize() < 3)
throw new RuntimeException("Expected POSITION attribute to have at least 3 dimensions");
return fmt.getOffset(index);
}
@@ -160,7 +160,7 @@ public class QuadTransformer
throw new IllegalStateException("BLOCK format does not have normals?");
if (element.getType() != VertexFormatElement.Type.BYTE)
throw new RuntimeException("Expected NORMAL attribute to have data type BYTE");
if (element.getSize() < 3)
if (element.getByteSize() < 3)
throw new RuntimeException("Expected NORMAL attribute to have at least 3 dimensions");
return fmt.getOffset(index);
}
@@ -172,11 +172,11 @@ public class QuadTransformer
*/
public BakedQuad processOne(BakedQuad input)
{
int[] inData = input.getVertexData();
int[] inData = input.getVertices();
int[] outData = Arrays.copyOf(inData, inData.length);
processVertices(inData, outData);
return new BakedQuad(outData, input.getTintIndex(), input.getFace(), input.getSprite(), input.applyDiffuseLighting());
return new BakedQuad(outData, input.getTintIndex(), input.getDirection(), input.getSprite(), input.isShade());
}
/**
@@ -186,7 +186,7 @@ public class QuadTransformer
*/
public BakedQuad processOneInPlace(BakedQuad input)
{
int[] data = input.getVertexData();
int[] data = input.getVertices();
processVertices(data, data);
return input;
}
@@ -204,11 +204,11 @@ public class QuadTransformer
List<BakedQuad> outputs = Lists.newArrayList();
for(BakedQuad input : inputs)
{
int[] inData = input.getVertexData();
int[] inData = input.getVertices();
int[] outData = Arrays.copyOf(inData, inData.length);
processVertices(inData, outData);
outputs.add(new BakedQuad(outData, input.getTintIndex(), input.getFace(), input.getSprite(), input.applyDiffuseLighting()));
outputs.add(new BakedQuad(outData, input.getTintIndex(), input.getDirection(), input.getSprite(), input.isShade()));
}
return outputs;
}
@@ -224,7 +224,7 @@ public class QuadTransformer
for(BakedQuad input : inputs)
{
int[] data = input.getVertexData();
int[] data = input.getVertices();
processVertices(data, data);
}
}
@@ -57,9 +57,9 @@ public class SeparatePerspectiveModel implements IModelGeometry<SeparatePerspect
return new BakedModel(
owner.useSmoothLighting(), owner.isShadedInGui(), owner.isSideLit(),
spriteGetter.apply(owner.resolveTexture("particle")), overrides,
baseModel.bakeModel(bakery, baseModel, spriteGetter, modelTransform, modelLocation, owner.isSideLit()),
baseModel.bake(bakery, baseModel, spriteGetter, modelTransform, modelLocation, owner.isSideLit()),
ImmutableMap.copyOf(Maps.transformValues(perspectives, value -> {
return value.bakeModel(bakery, value, spriteGetter, modelTransform, modelLocation, owner.isSideLit());
return value.bake(bakery, value, spriteGetter, modelTransform, modelLocation, owner.isSideLit());
}))
);
}
@@ -68,9 +68,9 @@ public class SeparatePerspectiveModel implements IModelGeometry<SeparatePerspect
public Collection<RenderMaterial> getTextures(IModelConfiguration owner, Function<ResourceLocation, IUnbakedModel> modelGetter, Set<Pair<String, String>> missingTextureErrors)
{
Set<RenderMaterial> textures = Sets.newHashSet();
textures.addAll(baseModel.getTextures(modelGetter, missingTextureErrors));
textures.addAll(baseModel.getMaterials(modelGetter, missingTextureErrors));
for(BlockModel model : perspectives.values())
textures.addAll(model.getTextures(modelGetter, missingTextureErrors));
textures.addAll(model.getMaterials(modelGetter, missingTextureErrors));
return textures;
}
@@ -102,7 +102,7 @@ public class SeparatePerspectiveModel implements IModelGeometry<SeparatePerspect
}
@Override
public boolean isAmbientOcclusion()
public boolean useAmbientOcclusion()
{
return isAmbientOcclusion;
}
@@ -114,19 +114,19 @@ public class SeparatePerspectiveModel implements IModelGeometry<SeparatePerspect
}
@Override
public boolean isSideLit()
public boolean usesBlockLight()
{
return isSideLit;
}
@Override
public boolean isBuiltInRenderer()
public boolean isCustomRenderer()
{
return false;
}
@Override
public TextureAtlasSprite getParticleTexture()
public TextureAtlasSprite getParticleIcon()
{
return particle;
}
@@ -144,9 +144,9 @@ public class SeparatePerspectiveModel implements IModelGeometry<SeparatePerspect
}
@Override
public ItemCameraTransforms getItemCameraTransforms()
public ItemCameraTransforms getTransforms()
{
return ItemCameraTransforms.DEFAULT;
return ItemCameraTransforms.NO_TRANSFORMS;
}
@Override
@@ -186,16 +186,16 @@ public class SeparatePerspectiveModel implements IModelGeometry<SeparatePerspect
@Override
public SeparatePerspectiveModel read(JsonDeserializationContext deserializationContext, JsonObject modelContents)
{
BlockModel baseModel = deserializationContext.deserialize(JSONUtils.getJsonObject(modelContents, "base"), BlockModel.class);
BlockModel baseModel = deserializationContext.deserialize(JSONUtils.getAsJsonObject(modelContents, "base"), BlockModel.class);
JsonObject perspectiveData = JSONUtils.getJsonObject(modelContents, "perspectives");
JsonObject perspectiveData = JSONUtils.getAsJsonObject(modelContents, "perspectives");
ImmutableMap.Builder<ItemCameraTransforms.TransformType, BlockModel> perspectives = ImmutableMap.builder();
for(Map.Entry<String, ItemCameraTransforms.TransformType> perspective : PERSPECTIVES.entrySet())
{
if (perspectiveData.has(perspective.getKey()))
{
BlockModel perspectiveModel = deserializationContext.deserialize(JSONUtils.getJsonObject(perspectiveData, perspective.getKey()), BlockModel.class);
BlockModel perspectiveModel = deserializationContext.deserialize(JSONUtils.getAsJsonObject(perspectiveData, perspective.getKey()), BlockModel.class);
perspectives.put(perspective.getValue(), perspectiveModel);
}
}
@@ -63,7 +63,7 @@ public final class AnimationItemOverrideList extends ItemOverrideList
@SuppressWarnings("resource")
@Override
public IBakedModel getOverrideModel(IBakedModel originalModel, ItemStack stack, @Nullable ClientWorld world, @Nullable LivingEntity entity)
public IBakedModel resolve(IBakedModel originalModel, ItemStack stack, @Nullable ClientWorld world, @Nullable LivingEntity entity)
{
return stack.getCapability(CapabilityAnimation.ANIMATION_CAPABILITY, null)
.map(asm ->
@@ -72,16 +72,16 @@ public final class AnimationItemOverrideList extends ItemOverrideList
// TODO caching?
if(w == null && entity != null)
{
w = entity.world;
w = entity.level;
}
if(world == null)
{
w = Minecraft.getInstance().world;
w = Minecraft.getInstance().level;
}
return asm.apply(Animation.getWorldTime(world, Animation.getPartialTickTime())).getLeft();
})
// TODO where should uvlock data come from?
.map(state -> model.bakeModel(bakery, bakedTextureGetter, new ModelTransformComposition(state, this.state), modelLoc))
.orElseGet(() -> super.getOverrideModel(originalModel, stack, world, entity));
.map(state -> model.bake(bakery, bakedTextureGetter, new ModelTransformComposition(state, this.state), modelLoc))
.orElseGet(() -> super.resolve(originalModel, stack, world, entity));
}
}
@@ -540,7 +540,7 @@ public class ModelBlockAnimation
{
float w = info.getWeights().get(i)[0];
tmp = trOp.getMatrix();
tmp.mul(w);
tmp.multiply(w);
m.add(tmp);
weight += w;
}
@@ -548,7 +548,7 @@ public class ModelBlockAnimation
}
if(weight > 1e-5)
{
m.mul(1f / weight);
m.multiply(1f / weight);
return new TransformationMatrix(m);
}
}
@@ -64,17 +64,17 @@ public class TileEntityRendererAnimation<T extends TileEntity> extends TileEntit
{
return;
}
if(blockRenderer == null) blockRenderer = Minecraft.getInstance().getBlockRendererDispatcher();
BlockPos pos = te.getPos();
IBlockDisplayReader world = MinecraftForgeClient.getRegionRenderCacheOptional(te.getWorld(), pos)
.map(IBlockDisplayReader.class::cast).orElseGet(() -> te.getWorld());
if(blockRenderer == null) blockRenderer = Minecraft.getInstance().getBlockRenderer();
BlockPos pos = te.getBlockPos();
IBlockDisplayReader world = MinecraftForgeClient.getRegionRenderCacheOptional(te.getLevel(), pos)
.map(IBlockDisplayReader.class::cast).orElseGet(() -> te.getLevel());
BlockState state = world.getBlockState(pos);
IBakedModel model = blockRenderer.getBlockModelShapes().getModel(state);
IModelData data = model.getModelData(world, pos, state, ModelDataManager.getModelData(te.getWorld(), pos));
IBakedModel model = blockRenderer.getBlockModelShaper().getBlockModel(state);
IModelData data = model.getModelData(world, pos, state, ModelDataManager.getModelData(te.getLevel(), pos));
if (data.hasProperty(Properties.AnimationProperty))
{
@SuppressWarnings("resource")
float time = Animation.getWorldTime(Minecraft.getInstance().world, partialTick);
float time = Animation.getWorldTime(Minecraft.getInstance().level, partialTick);
cap
.map(asm -> asm.apply(time))
.ifPresent(pair -> {
@@ -82,7 +82,7 @@ public class TileEntityRendererAnimation<T extends TileEntity> extends TileEntit
// TODO: caching?
data.setData(Properties.AnimationProperty, pair.getLeft());
blockRenderer.getBlockModelRenderer().renderModel(world, model, state, pos, mat, renderer.getBuffer(Atlases.getSolidBlockType()), false, new Random(), 42, light, data);
blockRenderer.getModelRenderer().renderModel(world, model, state, pos, mat, renderer.getBuffer(Atlases.solidBlockSheet()), false, new Random(), 42, light, data);
});
}
}
@@ -447,10 +447,10 @@ public enum B3DLoader implements ISelectiveResourceReloadListener
@SuppressWarnings("deprecation")
@Override
public Collection<RenderMaterial> getTextures(Function<ResourceLocation, IUnbakedModel> modelGetter, Set<com.mojang.datafixers.util.Pair<String, String>> missingTextureErrors)
public Collection<RenderMaterial> getMaterials(Function<ResourceLocation, IUnbakedModel> modelGetter, Set<com.mojang.datafixers.util.Pair<String, String>> missingTextureErrors)
{
return textures.values().stream().filter(loc -> !loc.startsWith("#"))
.map(t -> new RenderMaterial(AtlasTexture.LOCATION_BLOCKS_TEXTURE, new ResourceLocation(t)))
.map(t -> new RenderMaterial(AtlasTexture.LOCATION_BLOCKS, new ResourceLocation(t)))
.collect(Collectors.toList());
}
@@ -463,10 +463,10 @@ public enum B3DLoader implements ISelectiveResourceReloadListener
@SuppressWarnings("deprecation")
@Nullable
@Override
public IBakedModel bakeModel(ModelBakery bakery, Function<RenderMaterial, TextureAtlasSprite> spriteGetter, IModelTransform modelTransform, ResourceLocation modelLocation)
public IBakedModel bake(ModelBakery bakery, Function<RenderMaterial, TextureAtlasSprite> spriteGetter, IModelTransform modelTransform, ResourceLocation modelLocation)
{
ImmutableMap.Builder<String, TextureAtlasSprite> builder = ImmutableMap.builder();
TextureAtlasSprite missing = spriteGetter.apply(new RenderMaterial(AtlasTexture.LOCATION_BLOCKS_TEXTURE, MissingTextureSprite.getLocation()));
TextureAtlasSprite missing = spriteGetter.apply(new RenderMaterial(AtlasTexture.LOCATION_BLOCKS, MissingTextureSprite.getLocation()));
for(Map.Entry<String, String> e : textures.entrySet())
{
if(e.getValue().startsWith("#"))
@@ -476,7 +476,7 @@ public enum B3DLoader implements ISelectiveResourceReloadListener
}
else
{
builder.put(e.getKey(), spriteGetter.apply(new RenderMaterial(AtlasTexture.LOCATION_BLOCKS_TEXTURE, new ResourceLocation(e.getValue()))));
builder.put(e.getKey(), spriteGetter.apply(new RenderMaterial(AtlasTexture.LOCATION_BLOCKS, new ResourceLocation(e.getValue()))));
}
}
builder.put("missingno", missing);
@@ -724,7 +724,7 @@ public enum B3DLoader implements ISelectiveResourceReloadListener
else sprite = this.textures.get(textures.get(0).getPath());
BakedQuadBuilder quadBuilder = new BakedQuadBuilder(sprite);
quadBuilder.setContractUVs(true);
quadBuilder.setQuadOrientation(Direction.getFacingFromVector(f.getNormal().getX(), f.getNormal().getY(), f.getNormal().getZ()));
quadBuilder.setQuadOrientation(Direction.getNearest(f.getNormal().x(), f.getNormal().y(), f.getNormal().z()));
putVertexData(quadBuilder, f.getV1(), f.getNormal(), sprite);
putVertexData(quadBuilder, f.getV2(), f.getNormal(), sprite);
putVertexData(quadBuilder, f.getV3(), f.getNormal(), sprite);
@@ -743,12 +743,12 @@ public enum B3DLoader implements ISelectiveResourceReloadListener
switch(vertexFormatElements.get(e).getUsage())
{
case POSITION:
consumer.put(e, v.getPos().getX(), v.getPos().getY(), v.getPos().getZ(), 1);
consumer.put(e, v.getPos().x(), v.getPos().y(), v.getPos().z(), 1);
break;
case COLOR:
if(v.getColor() != null)
{
consumer.put(e, v.getColor().getX(), v.getColor().getY(), v.getColor().getZ(), v.getColor().getW());
consumer.put(e, v.getColor().x(), v.getColor().y(), v.getColor().z(), v.getColor().w());
}
else
{
@@ -760,8 +760,8 @@ public enum B3DLoader implements ISelectiveResourceReloadListener
if(vertexFormatElements.get(e).getIndex() < v.getTexCoords().length)
{
consumer.put(e,
sprite.getInterpolatedU(v.getTexCoords()[0].getX() * 16),
sprite.getInterpolatedV(v.getTexCoords()[0].getY() * 16),
sprite.getU(v.getTexCoords()[0].x() * 16),
sprite.getV(v.getTexCoords()[0].y() * 16),
0,
1
);
@@ -774,11 +774,11 @@ public enum B3DLoader implements ISelectiveResourceReloadListener
case NORMAL:
if(v.getNormal() != null)
{
consumer.put(e, v.getNormal().getX(), v.getNormal().getY(), v.getNormal().getZ(), 0);
consumer.put(e, v.getNormal().x(), v.getNormal().y(), v.getNormal().z(), 0);
}
else
{
consumer.put(e, faceNormal.getX(), faceNormal.getY(), faceNormal.getZ(), 0);
consumer.put(e, faceNormal.x(), faceNormal.y(), faceNormal.z(), 0);
}
break;
default:
@@ -788,7 +788,7 @@ public enum B3DLoader implements ISelectiveResourceReloadListener
}
@Override
public boolean isAmbientOcclusion()
public boolean useAmbientOcclusion()
{
return smooth;
}
@@ -800,19 +800,19 @@ public enum B3DLoader implements ISelectiveResourceReloadListener
}
@Override
public boolean isSideLit()
public boolean usesBlockLight()
{
return isSideLit;
}
@Override
public boolean isBuiltInRenderer()
public boolean isCustomRenderer()
{
return false;
}
@Override
public TextureAtlasSprite getParticleTexture()
public TextureAtlasSprite getParticleIcon()
{
// FIXME somehow specify particle texture in the model
return textures.values().asList().get(0);
@@ -670,10 +670,10 @@ public class B3DModel
{
totalWeight += bone.getLeft();
Matrix4f bm = animator.apply(bone.getRight());
bm.mul(bone.getLeft());
bm.multiply(bone.getLeft());
t.add(bm);
}
if(Math.abs(totalWeight) > 1e-4) t.mul(1f / totalWeight);
if(Math.abs(totalWeight) > 1e-4) t.multiply(1f / totalWeight);
else t.setIdentity();
}
@@ -684,7 +684,7 @@ public class B3DModel
pos.setW(1);
trsr.transformPosition(pos);
pos.normalize();
Vector3f rPos = new Vector3f(pos.getX(), pos.getY(), pos.getZ());
Vector3f rPos = new Vector3f(pos.x(), pos.y(), pos.z());
// normal
Vector3f rNormal = null;
@@ -101,7 +101,7 @@ public abstract class BlockStateProvider implements IDataProvider {
}
@Override
public void act(DirectoryCache cache) throws IOException {
public void run(DirectoryCache cache) throws IOException {
models().clear();
itemModels().clear();
registeredBlocks.clear();
@@ -241,7 +241,7 @@ public abstract class BlockStateProvider implements IDataProvider {
getVariantBuilder(block)
.forAllStates(state -> ConfiguredModel.builder()
.modelFile(modelFunc.apply(state))
.rotationY(((int) state.get(BlockStateProperties.HORIZONTAL_FACING).getHorizontalAngle() + angleOffset) % 360)
.rotationY(((int) state.getValue(BlockStateProperties.HORIZONTAL_FACING).toYRot() + angleOffset) % 360)
.build()
);
}
@@ -262,8 +262,8 @@ public abstract class BlockStateProvider implements IDataProvider {
getVariantBuilder(block)
.forAllStates(state -> ConfiguredModel.builder()
.modelFile(modelFunc.apply(state))
.rotationX(state.get(BlockStateProperties.FACE).ordinal() * 90)
.rotationY((((int) state.get(BlockStateProperties.HORIZONTAL_FACING).getHorizontalAngle() + angleOffset) + (state.get(BlockStateProperties.FACE) == AttachFace.CEILING ? 180 : 0)) % 360)
.rotationX(state.getValue(BlockStateProperties.ATTACH_FACE).ordinal() * 90)
.rotationY((((int) state.getValue(BlockStateProperties.HORIZONTAL_FACING).toYRot() + angleOffset) + (state.getValue(BlockStateProperties.ATTACH_FACE) == AttachFace.CEILING ? 180 : 0)) % 360)
.build()
);
}
@@ -283,11 +283,11 @@ public abstract class BlockStateProvider implements IDataProvider {
public void directionalBlock(Block block, Function<BlockState, ModelFile> modelFunc, int angleOffset) {
getVariantBuilder(block)
.forAllStates(state -> {
Direction dir = state.get(BlockStateProperties.FACING);
Direction dir = state.getValue(BlockStateProperties.FACING);
return ConfiguredModel.builder()
.modelFile(modelFunc.apply(state))
.rotationX(dir == Direction.DOWN ? 180 : dir.getAxis().isHorizontal() ? 90 : 0)
.rotationY(dir.getAxis().isVertical() ? 0 : (((int) dir.getHorizontalAngle()) + angleOffset) % 360)
.rotationY(dir.getAxis().isVertical() ? 0 : (((int) dir.toYRot()) + angleOffset) % 360)
.build();
});
}
@@ -318,10 +318,10 @@ public abstract class BlockStateProvider implements IDataProvider {
public void stairsBlock(StairsBlock block, ModelFile stairs, ModelFile stairsInner, ModelFile stairsOuter) {
getVariantBuilder(block)
.forAllStatesExcept(state -> {
Direction facing = state.get(StairsBlock.FACING);
Half half = state.get(StairsBlock.HALF);
StairsShape shape = state.get(StairsBlock.SHAPE);
int yRot = (int) facing.rotateY().getHorizontalAngle(); // Stairs model is rotated 90 degrees clockwise for some reason
Direction facing = state.getValue(StairsBlock.FACING);
Half half = state.getValue(StairsBlock.HALF);
StairsShape shape = state.getValue(StairsBlock.SHAPE);
int yRot = (int) facing.getClockWise().toYRot(); // Stairs model is rotated 90 degrees clockwise for some reason
if (shape == StairsShape.INNER_LEFT || shape == StairsShape.OUTER_LEFT) {
yRot += 270; // Left facing stairs are rotated 90 degrees clockwise
}
@@ -361,10 +361,10 @@ public abstract class BlockStateProvider implements IDataProvider {
}
public void fourWayMultipart(MultiPartBlockStateBuilder builder, ModelFile side) {
SixWayBlock.FACING_TO_PROPERTY_MAP.entrySet().forEach(e -> {
SixWayBlock.PROPERTY_BY_DIRECTION.entrySet().forEach(e -> {
Direction dir = e.getKey();
if (dir.getAxis().isHorizontal()) {
builder.part().modelFile(side).rotationY((((int) dir.getHorizontalAngle()) + 180) % 360).uvLock(true).addModel()
builder.part().modelFile(side).rotationY((((int) dir.toYRot()) + 180) % 360).uvLock(true).addModel()
.condition(e.getValue(), true);
}
});
@@ -398,15 +398,15 @@ public abstract class BlockStateProvider implements IDataProvider {
public void fenceGateBlock(FenceGateBlock block, ModelFile gate, ModelFile gateOpen, ModelFile gateWall, ModelFile gateWallOpen) {
getVariantBuilder(block).forAllStatesExcept(state -> {
ModelFile model = gate;
if (state.get(FenceGateBlock.IN_WALL)) {
if (state.getValue(FenceGateBlock.IN_WALL)) {
model = gateWall;
}
if (state.get(FenceGateBlock.OPEN)) {
if (state.getValue(FenceGateBlock.OPEN)) {
model = model == gateWall ? gateWallOpen : gateOpen;
}
return ConfiguredModel.builder()
.modelFile(model)
.rotationY((int) state.get(FenceGateBlock.HORIZONTAL_FACING).getHorizontalAngle())
.rotationY((int) state.getValue(FenceGateBlock.FACING).toYRot())
.uvLock(true)
.build();
}, FenceGateBlock.POWERED);
@@ -425,10 +425,10 @@ public abstract class BlockStateProvider implements IDataProvider {
}
public static final ImmutableMap<Direction, Property<WallHeight>> WALL_PROPS = ImmutableMap.<Direction, Property<WallHeight>>builder()
.put(Direction.EAST, BlockStateProperties.WALL_HEIGHT_EAST)
.put(Direction.NORTH, BlockStateProperties.WALL_HEIGHT_NORTH)
.put(Direction.SOUTH, BlockStateProperties.WALL_HEIGHT_SOUTH)
.put(Direction.WEST, BlockStateProperties.WALL_HEIGHT_WEST)
.put(Direction.EAST, BlockStateProperties.EAST_WALL)
.put(Direction.NORTH, BlockStateProperties.NORTH_WALL)
.put(Direction.SOUTH, BlockStateProperties.SOUTH_WALL)
.put(Direction.WEST, BlockStateProperties.WEST_WALL)
.build();
public void wallBlock(WallBlock block, ModelFile post, ModelFile side, ModelFile sideTall) {
@@ -446,7 +446,7 @@ public abstract class BlockStateProvider implements IDataProvider {
private void wallSidePart(MultiPartBlockStateBuilder builder, ModelFile model, Map.Entry<Direction, Property<WallHeight>> entry, WallHeight height) {
builder.part()
.modelFile(model)
.rotationY((((int) entry.getKey().getHorizontalAngle()) + 180) % 360)
.rotationY((((int) entry.getKey().toYRot()) + 180) % 360)
.uvLock(true)
.addModel()
.condition(entry.getValue(), height);
@@ -472,7 +472,7 @@ public abstract class BlockStateProvider implements IDataProvider {
public void paneBlock(PaneBlock block, ModelFile post, ModelFile side, ModelFile sideAlt, ModelFile noSide, ModelFile noSideAlt) {
MultiPartBlockStateBuilder builder = getMultipartBuilder(block)
.part().modelFile(post).addModel().end();
SixWayBlock.FACING_TO_PROPERTY_MAP.entrySet().forEach(e -> {
SixWayBlock.PROPERTY_BY_DIRECTION.entrySet().forEach(e -> {
Direction dir = e.getKey();
if (dir.getAxis().isHorizontal()) {
boolean alt = dir == Direction.SOUTH;
@@ -502,9 +502,9 @@ public abstract class BlockStateProvider implements IDataProvider {
public void doorBlock(DoorBlock block, ModelFile bottomLeft, ModelFile bottomRight, ModelFile topLeft, ModelFile topRight) {
getVariantBuilder(block).forAllStatesExcept(state -> {
int yRot = ((int) state.get(DoorBlock.FACING).getHorizontalAngle()) + 90;
boolean rh = state.get(DoorBlock.HINGE) == DoorHingeSide.RIGHT;
boolean open = state.get(DoorBlock.OPEN);
int yRot = ((int) state.getValue(DoorBlock.FACING).toYRot()) + 90;
boolean rh = state.getValue(DoorBlock.HINGE) == DoorHingeSide.RIGHT;
boolean open = state.getValue(DoorBlock.OPEN);
boolean right = rh ^ open;
if (open) {
yRot += 90;
@@ -513,7 +513,7 @@ public abstract class BlockStateProvider implements IDataProvider {
yRot += 180;
}
yRot %= 360;
return ConfiguredModel.builder().modelFile(state.get(DoorBlock.HALF) == DoubleBlockHalf.LOWER ? (right ? bottomRight : bottomLeft) : (right ? topRight : topLeft))
return ConfiguredModel.builder().modelFile(state.getValue(DoorBlock.HALF) == DoubleBlockHalf.LOWER ? (right ? bottomRight : bottomLeft) : (right ? topRight : topLeft))
.rotationY(yRot)
.build();
}, DoorBlock.POWERED);
@@ -537,9 +537,9 @@ public abstract class BlockStateProvider implements IDataProvider {
public void trapdoorBlock(TrapDoorBlock block, ModelFile bottom, ModelFile top, ModelFile open, boolean orientable) {
getVariantBuilder(block).forAllStatesExcept(state -> {
int xRot = 0;
int yRot = ((int) state.get(TrapDoorBlock.HORIZONTAL_FACING).getHorizontalAngle()) + 180;
boolean isOpen = state.get(TrapDoorBlock.OPEN);
if (orientable && isOpen && state.get(TrapDoorBlock.HALF) == Half.TOP) {
int yRot = ((int) state.getValue(TrapDoorBlock.FACING).toYRot()) + 180;
boolean isOpen = state.getValue(TrapDoorBlock.OPEN);
if (orientable && isOpen && state.getValue(TrapDoorBlock.HALF) == Half.TOP) {
xRot += 180;
yRot += 180;
}
@@ -547,7 +547,7 @@ public abstract class BlockStateProvider implements IDataProvider {
yRot = 0;
}
yRot %= 360;
return ConfiguredModel.builder().modelFile(isOpen ? open : state.get(TrapDoorBlock.HALF) == Half.TOP ? top : bottom)
return ConfiguredModel.builder().modelFile(isOpen ? open : state.getValue(TrapDoorBlock.HALF) == Half.TOP ? top : bottom)
.rotationX(xRot)
.rotationY(yRot)
.build();
@@ -135,7 +135,7 @@ public final class ConfiguredModel {
}
static void checkRotation(int rotationX, int rotationY) {
Preconditions.checkArgument(ModelRotation.getModelRotation(rotationX, rotationY) != null, "Invalid model rotation x=%d, y=%d", rotationX, rotationY);
Preconditions.checkArgument(ModelRotation.by(rotationX, rotationY) != null, "Invalid model rotation x=%d, y=%d", rotationX, rotationY);
}
static void checkWeight(int weight) {
@@ -235,14 +235,14 @@ public class ModelBuilder<T extends ModelBuilder<T>> extends ModelFile {
for (Entry<Perspective, ItemTransformVec3f> e : transforms.entrySet()) {
JsonObject transform = new JsonObject();
ItemTransformVec3f vec = e.getValue();
if (vec.equals(ItemTransformVec3f.DEFAULT)) continue;
if (!vec.rotation.equals(ItemTransformVec3f.Deserializer.ROTATION_DEFAULT)) {
if (vec.equals(ItemTransformVec3f.NO_TRANSFORM)) continue;
if (!vec.rotation.equals(ItemTransformVec3f.Deserializer.DEFAULT_ROTATION)) {
transform.add("rotation", serializeVector3f(vec.rotation));
}
if (!vec.translation.equals(ItemTransformVec3f.Deserializer.TRANSLATION_DEFAULT)) {
if (!vec.translation.equals(ItemTransformVec3f.Deserializer.DEFAULT_TRANSLATION)) {
transform.add("translation", serializeVector3f(e.getValue().translation));
}
if (!vec.scale.equals(ItemTransformVec3f.Deserializer.SCALE_DEFAULT)) {
if (!vec.scale.equals(ItemTransformVec3f.Deserializer.DEFAULT_SCALE)) {
transform.add("scale", serializeVector3f(e.getValue().scale));
}
display.add(e.getKey().name, transform);
@@ -262,16 +262,16 @@ public class ModelBuilder<T extends ModelBuilder<T>> extends ModelFile {
JsonArray elements = new JsonArray();
this.elements.stream().map(ElementBuilder::build).forEach(part -> {
JsonObject partObj = new JsonObject();
partObj.add("from", serializeVector3f(part.positionFrom));
partObj.add("to", serializeVector3f(part.positionTo));
partObj.add("from", serializeVector3f(part.from));
partObj.add("to", serializeVector3f(part.to));
if (part.partRotation != null) {
if (part.rotation != null) {
JsonObject rotation = new JsonObject();
rotation.add("origin", serializeVector3f(part.partRotation.origin));
rotation.addProperty("axis", part.partRotation.axis.getString());
rotation.addProperty("angle", part.partRotation.angle);
if (part.partRotation.rescale) {
rotation.addProperty("rescale", part.partRotation.rescale);
rotation.add("origin", serializeVector3f(part.rotation.origin));
rotation.addProperty("axis", part.rotation.axis.getSerializedName());
rotation.addProperty("angle", part.rotation.angle);
if (part.rotation.rescale) {
rotation.addProperty("rescale", part.rotation.rescale);
}
partObj.add("rotation", rotation);
}
@@ -282,26 +282,26 @@ public class ModelBuilder<T extends ModelBuilder<T>> extends ModelFile {
JsonObject faces = new JsonObject();
for (Direction dir : Direction.values()) {
BlockPartFace face = part.mapFaces.get(dir);
BlockPartFace face = part.faces.get(dir);
if (face == null) continue;
JsonObject faceObj = new JsonObject();
faceObj.addProperty("texture", serializeLocOrKey(face.texture));
if (!Arrays.equals(face.blockFaceUV.uvs, part.getFaceUvs(dir))) {
faceObj.add("uv", new Gson().toJsonTree(face.blockFaceUV.uvs));
if (!Arrays.equals(face.uv.uvs, part.uvsByFace(dir))) {
faceObj.add("uv", new Gson().toJsonTree(face.uv.uvs));
}
if (face.cullFace != null) {
faceObj.addProperty("cullface", face.cullFace.getString());
if (face.cullForDirection != null) {
faceObj.addProperty("cullface", face.cullForDirection.getSerializedName());
}
if (face.blockFaceUV.rotation != 0) {
faceObj.addProperty("rotation", face.blockFaceUV.rotation);
if (face.uv.rotation != 0) {
faceObj.addProperty("rotation", face.uv.rotation);
}
if (face.tintIndex != -1) {
faceObj.addProperty("tintindex", face.tintIndex);
}
faces.add(dir.getString(), faceObj);
faces.add(dir.getSerializedName(), faceObj);
}
if (!part.mapFaces.isEmpty()) {
if (!part.faces.isEmpty()) {
partObj.add("faces", faces);
}
elements.add(partObj);
@@ -324,9 +324,9 @@ public class ModelBuilder<T extends ModelBuilder<T>> extends ModelFile {
private JsonArray serializeVector3f(Vector3f vec) {
JsonArray ret = new JsonArray();
ret.add(serializeFloat(vec.getX()));
ret.add(serializeFloat(vec.getY()));
ret.add(serializeFloat(vec.getZ()));
ret.add(serializeFloat(vec.x()));
ret.add(serializeFloat(vec.y()));
ret.add(serializeFloat(vec.z()));
return ret;
}
@@ -350,9 +350,9 @@ public class ModelBuilder<T extends ModelBuilder<T>> extends ModelFile {
}
private void validatePosition(Vector3f pos) {
validateCoordinate(pos.getX(), 'x');
validateCoordinate(pos.getY(), 'y');
validateCoordinate(pos.getZ(), 'z');
validateCoordinate(pos.x(), 'x');
validateCoordinate(pos.y(), 'y');
validateCoordinate(pos.z(), 'z');
}
/**
@@ -363,7 +363,7 @@ public abstract class ModelProvider<T extends ModelBuilder<T>> implements IDataP
}
@Override
public void act(DirectoryCache cache) throws IOException {
public void run(DirectoryCache cache) throws IOException {
clear();
registerModels();
generateAll(cache);
@@ -138,7 +138,7 @@ public final class MultiPartBlockStateBuilder implements IGeneratedBlockstate {
}
public boolean canApplyTo(Block b) {
return b.getStateContainer().getProperties().containsAll(conditions.keySet());
return b.getStateDefinition().getProperties().containsAll(conditions.keySet());
}
}
}
@@ -86,7 +86,7 @@ public class VariantBlockStateBuilder implements IGeneratedBlockstate {
@Override
public JsonObject toJson() {
List<BlockState> missingStates = Lists.newArrayList(owner.getStateContainer().getValidStates());
List<BlockState> missingStates = Lists.newArrayList(owner.getStateDefinition().getPossibleStates());
missingStates.removeAll(coveredStates);
Preconditions.checkState(missingStates.isEmpty(), "Blockstate for block %s does not cover all states. Missing: %s", owner, missingStates);
JsonObject variants = new JsonObject();
@@ -119,7 +119,7 @@ public class VariantBlockStateBuilder implements IGeneratedBlockstate {
if (!this.models.containsKey(state)) {
Preconditions.checkArgument(disjointToAll(state), "Cannot set models for a state for which a partial match has already been configured");
this.models.put(state, new ConfiguredModelList(models));
for (BlockState fullState : owner.getStateContainer().getValidStates()) {
for (BlockState fullState : owner.getStateDefinition().getPossibleStates()) {
if (state.test(fullState)) {
coveredStates.add(fullState);
}
@@ -162,7 +162,7 @@ public class VariantBlockStateBuilder implements IGeneratedBlockstate {
public VariantBlockStateBuilder forAllStatesExcept(Function<BlockState, ConfiguredModel[]> mapper, Property<?>... ignored) {
Set<PartialBlockstate> seen = new HashSet<>();
for (BlockState fullState : owner.getStateContainer().getValidStates()) {
for (BlockState fullState : owner.getStateDefinition().getPossibleStates()) {
Map<Property<?>, Comparable<?>> propertyValues = Maps.newLinkedHashMap(fullState.getValues());
for (Property<?> p : ignored) {
propertyValues.remove(p);
@@ -191,8 +191,8 @@ public class VariantBlockStateBuilder implements IGeneratedBlockstate {
for (Map.Entry<Property<?>, Comparable<?>> entry : setStates.entrySet()) {
Property<?> prop = entry.getKey();
Comparable<?> value = entry.getValue();
Preconditions.checkArgument(owner.getStateContainer().getProperties().contains(prop), "Property %s not found on block %s", entry, this.owner);
Preconditions.checkArgument(prop.getAllowedValues().contains(value), "%s is not a valid value for %s", value, prop);
Preconditions.checkArgument(owner.getStateDefinition().getProperties().contains(prop), "Property %s not found on block %s", entry, this.owner);
Preconditions.checkArgument(prop.getPossibleValues().contains(value), "%s is not a valid value for %s", value, prop);
}
this.setStates = Maps.newTreeMap(Comparator.comparing(Property::getName));
this.setStates.putAll(setStates);
@@ -291,7 +291,7 @@ public class VariantBlockStateBuilder implements IGeneratedBlockstate {
return false;
}
for (Map.Entry<Property<?>, Comparable<?>> entry : setStates.entrySet()) {
if (blockState.get(entry.getKey()) != entry.getValue()) {
if (blockState.getValue(entry.getKey()) != entry.getValue()) {
return false;
}
}
@@ -59,12 +59,12 @@ public class OBJLoader implements IModelLoader<OBJModel>
String modelLocation = modelContents.get("model").getAsString();
boolean detectCullableFaces = JSONUtils.getBoolean(modelContents, "detectCullableFaces", true);
boolean diffuseLighting = JSONUtils.getBoolean(modelContents, "diffuseLighting", false);
boolean flipV = JSONUtils.getBoolean(modelContents, "flip-v", false);
boolean ambientToFullbright = JSONUtils.getBoolean(modelContents, "ambientToFullbright", true);
boolean detectCullableFaces = JSONUtils.getAsBoolean(modelContents, "detectCullableFaces", true);
boolean diffuseLighting = JSONUtils.getAsBoolean(modelContents, "diffuseLighting", false);
boolean flipV = JSONUtils.getAsBoolean(modelContents, "flip-v", false);
boolean ambientToFullbright = JSONUtils.getAsBoolean(modelContents, "ambientToFullbright", true);
@Nullable
String materialLibraryOverrideLocation = modelContents.has("materialLibraryOverride") ? JSONUtils.getString(modelContents, "materialLibraryOverride") : null;
String materialLibraryOverrideLocation = modelContents.has("materialLibraryOverride") ? JSONUtils.getAsString(modelContents, "materialLibraryOverride") : null;
return loadModel(new OBJModel.ModelSettings(new ResourceLocation(modelLocation), detectCullableFaces, diffuseLighting, flipV, ambientToFullbright, materialLibraryOverrideLocation));
}
@@ -287,9 +287,9 @@ public class OBJModel implements IMultipartModelGeometry<OBJModel>
{
Vector4f vec4 = parseVector4(line);
return new Vector3f(
vec4.getX() / vec4.getW(),
vec4.getY() / vec4.getW(),
vec4.getZ() / vec4.getW()
vec4.x() / vec4.w(),
vec4.y() / vec4.w(),
vec4.z() / vec4.w()
);
}
}
@@ -368,7 +368,7 @@ public class OBJModel implements IMultipartModelGeometry<OBJModel>
Vector2f uv2 = new Vector2f(0, 0);
if (ambientToFullbright)
{
int fakeLight = (int) ((ambientColor.getX() + ambientColor.getY() + ambientColor.getZ()) * 15 / 3.0f);
int fakeLight = (int) ((ambientColor.x() + ambientColor.y() + ambientColor.z()) * 15 / 3.0f);
uv2 = new Vector2f((fakeLight << 4) / 32767.0f, (fakeLight << 4) / 32767.0f);
builder.setApplyDiffuseLighting(fakeLight == 0);
}
@@ -397,65 +397,65 @@ public class OBJModel implements IMultipartModelGeometry<OBJModel>
transformation.transformNormal(normal);
};
Vector4f tintedColor = new Vector4f(
color.getX() * colorTint.getX(),
color.getY() * colorTint.getY(),
color.getZ() * colorTint.getZ(),
color.getW() * colorTint.getW());
color.x() * colorTint.x(),
color.y() * colorTint.y(),
color.z() * colorTint.z(),
color.w() * colorTint.w());
putVertexData(builder, position, texCoord, normal, tintedColor, uv2, texture);
pos[i] = position;
norm[i] = normal;
}
builder.setQuadOrientation(Direction.getFacingFromVector(norm[0].getX(), norm[0].getY(),norm[0].getZ()));
builder.setQuadOrientation(Direction.getNearest(norm[0].x(), norm[0].y(),norm[0].z()));
Direction cull = null;
if (detectCullableFaces)
{
if (MathHelper.epsilonEquals(pos[0].getX(), 0) && // vertex.position.x
MathHelper.epsilonEquals(pos[1].getX(), 0) &&
MathHelper.epsilonEquals(pos[2].getX(), 0) &&
MathHelper.epsilonEquals(pos[3].getX(), 0) &&
norm[0].getX() < 0) // vertex.normal.x
if (MathHelper.equal(pos[0].x(), 0) && // vertex.position.x
MathHelper.equal(pos[1].x(), 0) &&
MathHelper.equal(pos[2].x(), 0) &&
MathHelper.equal(pos[3].x(), 0) &&
norm[0].x() < 0) // vertex.normal.x
{
cull = Direction.WEST;
}
else if (MathHelper.epsilonEquals(pos[0].getX(), 1) && // vertex.position.x
MathHelper.epsilonEquals(pos[1].getX(), 1) &&
MathHelper.epsilonEquals(pos[2].getX(), 1) &&
MathHelper.epsilonEquals(pos[3].getX(), 1) &&
norm[0].getX() > 0) // vertex.normal.x
else if (MathHelper.equal(pos[0].x(), 1) && // vertex.position.x
MathHelper.equal(pos[1].x(), 1) &&
MathHelper.equal(pos[2].x(), 1) &&
MathHelper.equal(pos[3].x(), 1) &&
norm[0].x() > 0) // vertex.normal.x
{
cull = Direction.EAST;
}
else if (MathHelper.epsilonEquals(pos[0].getZ(), 0) && // vertex.position.z
MathHelper.epsilonEquals(pos[1].getZ(), 0) &&
MathHelper.epsilonEquals(pos[2].getZ(), 0) &&
MathHelper.epsilonEquals(pos[3].getZ(), 0) &&
norm[0].getZ() < 0) // vertex.normal.z
else if (MathHelper.equal(pos[0].z(), 0) && // vertex.position.z
MathHelper.equal(pos[1].z(), 0) &&
MathHelper.equal(pos[2].z(), 0) &&
MathHelper.equal(pos[3].z(), 0) &&
norm[0].z() < 0) // vertex.normal.z
{
cull = Direction.NORTH; // can never remember
}
else if (MathHelper.epsilonEquals(pos[0].getZ(), 1) && // vertex.position.z
MathHelper.epsilonEquals(pos[1].getZ(), 1) &&
MathHelper.epsilonEquals(pos[2].getZ(), 1) &&
MathHelper.epsilonEquals(pos[3].getZ(), 1) &&
norm[0].getZ() > 0) // vertex.normal.z
else if (MathHelper.equal(pos[0].z(), 1) && // vertex.position.z
MathHelper.equal(pos[1].z(), 1) &&
MathHelper.equal(pos[2].z(), 1) &&
MathHelper.equal(pos[3].z(), 1) &&
norm[0].z() > 0) // vertex.normal.z
{
cull = Direction.SOUTH;
}
else if (MathHelper.epsilonEquals(pos[0].getY(), 0) && // vertex.position.y
MathHelper.epsilonEquals(pos[1].getY(), 0) &&
MathHelper.epsilonEquals(pos[2].getY(), 0) &&
MathHelper.epsilonEquals(pos[3].getY(), 0) &&
norm[0].getY() < 0) // vertex.normal.z
else if (MathHelper.equal(pos[0].y(), 0) && // vertex.position.y
MathHelper.equal(pos[1].y(), 0) &&
MathHelper.equal(pos[2].y(), 0) &&
MathHelper.equal(pos[3].y(), 0) &&
norm[0].y() < 0) // vertex.normal.z
{
cull = Direction.DOWN; // can never remember
}
else if (MathHelper.epsilonEquals(pos[0].getY(), 1) && // vertex.position.y
MathHelper.epsilonEquals(pos[1].getY(), 1) &&
MathHelper.epsilonEquals(pos[2].getY(), 1) &&
MathHelper.epsilonEquals(pos[3].getY(), 1) &&
norm[0].getY() > 0) // vertex.normal.y
else if (MathHelper.equal(pos[0].y(), 1) && // vertex.position.y
MathHelper.equal(pos[1].y(), 1) &&
MathHelper.equal(pos[2].y(), 1) &&
MathHelper.equal(pos[3].y(), 1) &&
norm[0].y() > 0) // vertex.normal.y
{
cull = Direction.UP;
}
@@ -473,18 +473,18 @@ public class OBJModel implements IMultipartModelGeometry<OBJModel>
switch(e.getUsage())
{
case POSITION:
consumer.put(j, position0.getX(), position0.getY(), position0.getZ(), position0.getW());
consumer.put(j, position0.x(), position0.y(), position0.z(), position0.w());
break;
case COLOR:
consumer.put(j, color0.getX(), color0.getY(), color0.getZ(), color0.getW());
consumer.put(j, color0.x(), color0.y(), color0.z(), color0.w());
break;
case UV:
switch (e.getIndex())
{
case 0:
consumer.put(j,
texture.getInterpolatedU(texCoord0.x * 16),
texture.getInterpolatedV((flipV ? (1 - texCoord0.y) : texCoord0.y) * 16)
texture.getU(texCoord0.x * 16),
texture.getV((flipV ? (1 - texCoord0.y) : texCoord0.y) * 16)
);
break;
case 2:
@@ -496,7 +496,7 @@ public class OBJModel implements IMultipartModelGeometry<OBJModel>
}
break;
case NORMAL:
consumer.put(j, normal0.getX(), normal0.getY(), normal0.getZ());
consumer.put(j, normal0.x(), normal0.y(), normal0.z());
break;
default:
consumer.put(j);
@@ -129,8 +129,8 @@ public class BakedQuadBuilder implements IVertexConsumer
}
if(contractUVs)
{
float tX = texture.getWidth() / (texture.getMaxU() - texture.getMinU());
float tY = texture.getHeight() / (texture.getMaxV() - texture.getMinV());
float tX = texture.getWidth() / (texture.getU1() - texture.getU0());
float tY = texture.getHeight() / (texture.getV1() - texture.getV0());
float tS = tX > tY ? tX : tY;
float ep = 1f / (tS * 0x100);
int uve = 0;
@@ -119,29 +119,29 @@ public class BlockInfo
{
for(int z = 0; z <= 2; z++)
{
BlockPos pos = blockPos.add(x - 1, y - 1, z - 1);
BlockPos pos = blockPos.offset(x - 1, y - 1, z - 1);
BlockState state = world.getBlockState(pos);
t[x][y][z] = state.getOpacity(world, pos) < 15;
int brightness = WorldRenderer.getCombinedLight(world, pos);
s[x][y][z] = LightTexture.getLightSky(brightness);
b[x][y][z] = LightTexture.getLightBlock(brightness);
ao[x][y][z] = state.getAmbientOcclusionLightValue(world, pos);
t[x][y][z] = state.getLightBlock(world, pos) < 15;
int brightness = WorldRenderer.getLightColor(world, pos);
s[x][y][z] = LightTexture.sky(brightness);
b[x][y][z] = LightTexture.block(brightness);
ao[x][y][z] = state.getShadeBrightness(world, pos);
}
}
}
for(Direction side : SIDES)
{
BlockPos pos = blockPos.offset(side);
BlockPos pos = blockPos.relative(side);
BlockState state = world.getBlockState(pos);
BlockState thisStateShape = this.state.isSolid() && this.state.isTransparent() ? this.state : Blocks.AIR.getDefaultState();
BlockState otherStateShape = state.isSolid() && state.isTransparent() ? state : Blocks.AIR.getDefaultState();
BlockState thisStateShape = this.state.canOcclude() && this.state.useShapeForLightOcclusion() ? this.state : Blocks.AIR.defaultBlockState();
BlockState otherStateShape = state.canOcclude() && state.useShapeForLightOcclusion() ? state : Blocks.AIR.defaultBlockState();
if(state.getOpacity(world, pos) == 15 || VoxelShapes.faceShapeCovers(thisStateShape.getFaceOcclusionShape(world, blockPos, side), otherStateShape.getFaceOcclusionShape(world, pos, side.getOpposite())))
if(state.getLightBlock(world, pos) == 15 || VoxelShapes.faceShapeOccludes(thisStateShape.getFaceOcclusionShape(world, blockPos, side), otherStateShape.getFaceOcclusionShape(world, pos, side.getOpposite())))
{
int x = side.getXOffset() + 1;
int y = side.getYOffset() + 1;
int z = side.getZOffset() + 1;
int x = side.getStepX() + 1;
int y = side.getStepY() + 1;
int z = side.getStepZ() + 1;
s[x][y][z] = Math.max(s[1][1][1] - 1, s[x][y][z]);
b[x][y][z] = Math.max(b[1][1][1] - 1, b[x][y][z]);
}
@@ -189,13 +189,13 @@ public class BlockInfo
public void updateFlatLighting()
{
full = Block.isOpaque(state.getCollisionShape(world, blockPos));
packed[0] = WorldRenderer.getCombinedLight(world, blockPos);
full = Block.isShapeFullBlock(state.getCollisionShape(world, blockPos));
packed[0] = WorldRenderer.getLightColor(world, blockPos);
for (Direction side : SIDES)
{
int i = side.ordinal() + 1;
packed[i] = WorldRenderer.getCombinedLight(world, blockPos.offset(side));
packed[i] = WorldRenderer.getLightColor(world, blockPos.relative(side));
}
}
@@ -60,7 +60,7 @@ public class ForgeBlockModelRenderer extends BlockModelRenderer
VertexLighterFlat lighter = lighterFlat.get();
lighter.setParent(consumer);
lighter.setTransform(matrixStack.getLast());
lighter.setTransform(matrixStack.last());
return render(lighter, world, model, state, pos, matrixStack, checkSides, rand, seed, modelData);
}
@@ -80,7 +80,7 @@ public class ForgeBlockModelRenderer extends BlockModelRenderer
VertexLighterSmoothAo lighter = lighterSmooth.get();
lighter.setParent(consumer);
lighter.setTransform(matrixStack.getLast());
lighter.setTransform(matrixStack.last());
return render(lighter, world, model, state, pos, matrixStack, checkSides, rand, seed, modelData);
}
@@ -113,7 +113,7 @@ public class ForgeBlockModelRenderer extends BlockModelRenderer
quads = model.getQuads(state, side, rand, modelData);
if(!quads.isEmpty())
{
if(!checkSides || Block.shouldSideBeRendered(state, world, pos, side))
if(!checkSides || Block.shouldRenderFace(state, world, pos, side))
{
if(empty) lighter.updateBlockInfo();
empty = false;
@@ -88,12 +88,12 @@ public class LightUtil
public static void putBakedQuad(IVertexConsumer consumer, BakedQuad quad)
{
consumer.setTexture(quad.getSprite());
consumer.setQuadOrientation(quad.getFace());
if(quad.hasTintIndex())
consumer.setQuadOrientation(quad.getDirection());
if(quad.isTinted())
{
consumer.setQuadTint(quad.getTintIndex());
}
consumer.setApplyDiffuseLighting(quad.applyDiffuseLighting());
consumer.setApplyDiffuseLighting(quad.isShade());
float[] data = new float[4];
VertexFormat formatFrom = consumer.getVertexFormat();
VertexFormat formatTo = DefaultVertexFormats.BLOCK;
@@ -106,7 +106,7 @@ public class LightUtil
{
if(eMap[e] != countTo)
{
unpack(quad.getVertexData(), data, formatTo, v, eMap[e]);
unpack(quad.getVertices(), data, formatTo, v, eMap[e]);
consumer.put(e, data);
}
else
@@ -156,7 +156,7 @@ public class LightUtil
{
int length = 4 < to.length ? 4 : to.length;
VertexFormatElement element = formatFrom.getElements().get(e);
int vertexStart = v * formatFrom.getSize() + formatFrom.getOffset(e);
int vertexStart = v * formatFrom.getVertexSize() + formatFrom.getOffset(e);
int count = element.getElementCount();
VertexFormatElement.Type type = element.getType();
VertexFormatElement.Usage usage = element.getUsage();
@@ -211,7 +211,7 @@ public class LightUtil
public static void pack(float[] from, int[] to, VertexFormat formatTo, int v, int e)
{
VertexFormatElement element = formatTo.getElements().get(e);
int vertexStart = v * formatTo.getSize() + formatTo.getOffset(e);
int vertexStart = v * formatTo.getVertexSize() + formatTo.getOffset(e);
int count = element.getElementCount();
VertexFormatElement.Type type = element.getType();
int size = type.getSize();
@@ -255,7 +255,7 @@ public class LightUtil
public static void setLightData(BakedQuad q, int light)
{
int[] data = q.getVertexData();
int[] data = q.getVertices();
for (int i = 0; i < 4; i++)
{
data[getLightOffset(i)] = light;
@@ -41,17 +41,17 @@ public class TRSRTransformer extends VertexTransformer
case POSITION:
Vector4f pos = new Vector4f(data[0], data[1], data[2], data[3]);
transform.transformPosition(pos);
data[0] = pos.getX();
data[1] = pos.getY();
data[2] = pos.getZ();
data[3] = pos.getW();
data[0] = pos.x();
data[1] = pos.y();
data[2] = pos.z();
data[3] = pos.w();
break;
case NORMAL:
Vector3f normal = new Vector3f(data);
transform.transformNormal(normal);
data[0] = normal.getX();
data[1] = normal.getY();
data[2] = normal.getZ();
data[0] = normal.x();
data[1] = normal.y();
data[2] = normal.z();
break;
}
super.put(element, data);
@@ -57,7 +57,7 @@ public class VertexBufferConsumer implements IVertexConsumer
switch (e)
{
case 0: // POSITION_3F
renderer.pos(d0, d1, d2);
renderer.vertex(d0, d1, d2);
break;
case 4: // NORMAL_3B
renderer.normal(d0, d1, d2);
@@ -66,10 +66,10 @@ public class VertexBufferConsumer implements IVertexConsumer
renderer.color(d0, d1, d2, d3);
break;
case 2: // TEX_2F
renderer.tex(d0, d1);
renderer.uv(d0, d1);
break;
case 3: // TEX_2SB
renderer.lightmap((int) (d0 * 0xF0), (int) (d1 * 0xF0));
renderer.uv2((int) (d0 * 0xF0), (int) (d1 * 0xF0));
break;
case 5: // PADDING_1B
break;
@@ -45,7 +45,7 @@ public class VertexLighterFlat extends QuadGatheringTransformer
// TODO 1.16/1.17 possibly refactor out the need for the "unpacked" format entirely. It's creating more headaches than solutions.
// This mess reverses the conversion to float bits done in LightUtil.unpack
private static final int LIGHTMAP_PACKING_FACTOR = ((256 << (8 * (DefaultVertexFormats.TEX_2SB.getType().getSize() - 1))) - 1) >>> 1;
private static final int LIGHTMAP_PACKING_FACTOR = ((256 << (8 * (DefaultVertexFormats.ELEMENT_UV2.getType().getSize() - 1))) - 1) >>> 1;
// Max lightmap value, for rescaling
private static final int LIGHTMAP_MAX = 0xF0;
// Inlined factor for rescaling input lightmap values, "rounded" up to the next float value to avoid precision loss when result is truncated to int
@@ -172,9 +172,9 @@ public class VertexLighterFlat extends QuadGatheringTransformer
v2.normalize();
for(int v = 0; v < 4; v++)
{
normal[v][0] = v2.getX();
normal[v][1] = v2.getY();
normal[v][2] = v2.getZ();
normal[v][0] = v2.x();
normal[v][1] = v2.y();
normal[v][2] = v2.z();
normal[v][3] = 0;
}
}
@@ -227,20 +227,20 @@ public class VertexLighterFlat extends QuadGatheringTransformer
case POSITION:
final Vector4f pos = new Vector4f(
position[v][0], position[v][1], position[v][2], 1);
pos.transform(pose.getMatrix());
pos.transform(pose.pose());
position[v][0] = pos.getX();
position[v][1] = pos.getY();
position[v][2] = pos.getZ();
position[v][0] = pos.x();
position[v][1] = pos.y();
position[v][2] = pos.z();
parent.put(e, position[v]);
break;
case NORMAL:
final Vector3f norm = new Vector3f(normal[v]);
norm.transform(pose.getNormal());
norm.transform(pose.normal());
normal[v][0] = norm.getX();
normal[v][1] = norm.getY();
normal[v][2] = norm.getZ();
normal[v][0] = norm.x();
normal[v][1] = norm.y();
normal[v][2] = norm.z();
parent.put(e, normal[v]);
break;
case COLOR:
@@ -279,8 +279,8 @@ public class VertexLighterFlat extends QuadGatheringTransformer
int i = side == null ? 0 : side.ordinal() + 1;
int brightness = blockInfo.getPackedLight()[i];
lightmap[0] = LightTexture.getLightBlock(brightness) / (float) 0xF;
lightmap[1] = LightTexture.getLightSky(brightness) / (float) 0xF;
lightmap[0] = LightTexture.block(brightness) / (float) 0xF;
lightmap[1] = LightTexture.sky(brightness) / (float) 0xF;
}
protected void updateColor(float[] normal, float[] color, float x, float y, float z, float tint, int multiplier)
@@ -48,7 +48,7 @@ public enum KeyConflictContext implements IKeyConflictContext
@Override
public boolean isActive()
{
return Minecraft.getInstance().currentScreen != null;
return Minecraft.getInstance().screen != null;
}
@Override
@@ -37,8 +37,8 @@ public enum KeyModifier {
@Override
public boolean matches(InputMappings.Input key)
{
int keyCode = key.getKeyCode();
if (Minecraft.IS_RUNNING_ON_MAC)
int keyCode = key.getValue();
if (Minecraft.ON_OSX)
{
return keyCode == GLFW.GLFW_KEY_LEFT_ALT || keyCode == GLFW.GLFW_KEY_RIGHT_ALT;
}
@@ -57,7 +57,7 @@ public enum KeyModifier {
@Override
public ITextComponent getCombinedName(InputMappings.Input key, Supplier<ITextComponent> defaultLogic)
{
String localizationFormatKey = Minecraft.IS_RUNNING_ON_MAC ? "forge.controlsgui.control.mac" : "forge.controlsgui.control";
String localizationFormatKey = Minecraft.ON_OSX ? "forge.controlsgui.control.mac" : "forge.controlsgui.control";
return new TranslationTextComponent(localizationFormatKey, defaultLogic.get());
}
},
@@ -65,7 +65,7 @@ public enum KeyModifier {
@Override
public boolean matches(InputMappings.Input key)
{
return key.getKeyCode() == GLFW.GLFW_KEY_LEFT_SHIFT || key.getKeyCode() == GLFW.GLFW_KEY_RIGHT_SHIFT;
return key.getValue() == GLFW.GLFW_KEY_LEFT_SHIFT || key.getValue() == GLFW.GLFW_KEY_RIGHT_SHIFT;
}
@Override
@@ -84,7 +84,7 @@ public enum KeyModifier {
@Override
public boolean matches(InputMappings.Input key)
{
return key.getKeyCode() == GLFW.GLFW_KEY_LEFT_ALT || key.getKeyCode() == GLFW.GLFW_KEY_RIGHT_ALT;
return key.getValue() == GLFW.GLFW_KEY_LEFT_ALT || key.getValue() == GLFW.GLFW_KEY_RIGHT_ALT;
}
@Override
@@ -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");
@@ -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);
}
/**
Loaded 100 of 832 files, more files were not shown because too many files have changed in this diff. Show more