|
@@ -34,7 +34,7 @@ import net.minecraft.client.renderer.entity.EntityRendererManager;
|
|
|
import net.minecraft.client.world.ClientWorld;
|
|
|
import net.minecraft.entity.Entity;
|
|
|
import net.minecraft.item.BlockItem;
|
|
|
-import static net.minecraft.item.ItemModelsProperties.registerProperty;
|
|
|
+import net.minecraft.item.ItemModelsProperties;
|
|
|
import net.minecraft.item.ItemStack;
|
|
|
import net.minecraft.particles.ParticleTypes;
|
|
|
import net.minecraft.util.ResourceLocation;
|
|
@@ -72,27 +72,27 @@ public class Client {
|
|
|
}
|
|
|
|
|
|
private static void registerColors() {
|
|
|
- RenderTypeLookup.setRenderLayer(ModBlocks.lantern, RenderType.getTranslucent());
|
|
|
- RenderTypeLookup.setRenderLayer(ModBlocks.tallGrass, RenderType.getCutout());
|
|
|
- RenderTypeLookup.setRenderLayer(ModBlocks.cherrySapling, RenderType.getCutout());
|
|
|
- RenderTypeLookup.setRenderLayer(ModBlocks.apricotSapling, RenderType.getCutout());
|
|
|
- RenderTypeLookup.setRenderLayer(ModBlocks.pearSapling, RenderType.getCutout());
|
|
|
- RenderTypeLookup.setRenderLayer(ModBlocks.plumSapling, RenderType.getCutout());
|
|
|
- RenderTypeLookup.setRenderLayer(ModBlocks.cherryLeaves, RenderType.getCutoutMipped());
|
|
|
- RenderTypeLookup.setRenderLayer(ModBlocks.apricotLeaves, RenderType.getCutoutMipped());
|
|
|
- RenderTypeLookup.setRenderLayer(ModBlocks.pearLeaves, RenderType.getCutoutMipped());
|
|
|
- RenderTypeLookup.setRenderLayer(ModBlocks.plumLeaves, RenderType.getCutoutMipped());
|
|
|
- RenderTypeLookup.setRenderLayer(ModBlocks.wheat, RenderType.getCutout());
|
|
|
- RenderTypeLookup.setRenderLayer(ModBlocks.carrots, RenderType.getCutout());
|
|
|
- RenderTypeLookup.setRenderLayer(ModBlocks.potatoes, RenderType.getCutout());
|
|
|
- RenderTypeLookup.setRenderLayer(ModBlocks.beetroots, RenderType.getCutout());
|
|
|
+ RenderTypeLookup.setRenderLayer(ModBlocks.lantern, RenderType.translucent());
|
|
|
+ RenderTypeLookup.setRenderLayer(ModBlocks.tallGrass, RenderType.cutout());
|
|
|
+ RenderTypeLookup.setRenderLayer(ModBlocks.cherrySapling, RenderType.cutout());
|
|
|
+ RenderTypeLookup.setRenderLayer(ModBlocks.apricotSapling, RenderType.cutout());
|
|
|
+ RenderTypeLookup.setRenderLayer(ModBlocks.pearSapling, RenderType.cutout());
|
|
|
+ RenderTypeLookup.setRenderLayer(ModBlocks.plumSapling, RenderType.cutout());
|
|
|
+ RenderTypeLookup.setRenderLayer(ModBlocks.cherryLeaves, RenderType.cutoutMipped());
|
|
|
+ RenderTypeLookup.setRenderLayer(ModBlocks.apricotLeaves, RenderType.cutoutMipped());
|
|
|
+ RenderTypeLookup.setRenderLayer(ModBlocks.pearLeaves, RenderType.cutoutMipped());
|
|
|
+ RenderTypeLookup.setRenderLayer(ModBlocks.plumLeaves, RenderType.cutoutMipped());
|
|
|
+ RenderTypeLookup.setRenderLayer(ModBlocks.wheat, RenderType.cutout());
|
|
|
+ RenderTypeLookup.setRenderLayer(ModBlocks.carrots, RenderType.cutout());
|
|
|
+ RenderTypeLookup.setRenderLayer(ModBlocks.potatoes, RenderType.cutout());
|
|
|
+ RenderTypeLookup.setRenderLayer(ModBlocks.beetroots, RenderType.cutout());
|
|
|
|
|
|
BlockColors bColors = Minecraft.getInstance().getBlockColors();
|
|
|
bColors.register((state, w, pos, tintIndex) -> {
|
|
|
if(w == null || pos == null) {
|
|
|
return -16777216;
|
|
|
}
|
|
|
- TileEntityCookingPot tile = (TileEntityCookingPot) w.getTileEntity(pos);
|
|
|
+ TileEntityCookingPot tile = (TileEntityCookingPot) w.getBlockEntity(pos);
|
|
|
if(tile == null) {
|
|
|
return -16777216;
|
|
|
}
|
|
@@ -102,7 +102,7 @@ public class Client {
|
|
|
|
|
|
IBlockColor tallGrass = (state, w, pos, tintIndex) -> {
|
|
|
if(w != null && pos != null) {
|
|
|
- return BiomeColors.getGrassColor(w, pos);
|
|
|
+ return BiomeColors.getAverageGrassColor(w, pos);
|
|
|
}
|
|
|
return GrassColors.get(0.5D, 1.0D);
|
|
|
};
|
|
@@ -117,21 +117,23 @@ public class Client {
|
|
|
ModItems.gemStone, ModItems.rawGemStone, ModItems.flawlessGemStone);
|
|
|
|
|
|
iColors.register((stack, tintIndex) -> tallGrass.getColor(
|
|
|
- ((BlockItem) stack.getItem()).getBlock().getDefaultState(), null, null, tintIndex),
|
|
|
- ModBlocks.tallGrass);
|
|
|
-
|
|
|
- registerProperty(ModItems.sling, new ResourceLocation("pull"), (stack, w, ent) -> {
|
|
|
- if(ent == null) {
|
|
|
- return 0.0F;
|
|
|
- } else {
|
|
|
- return ent.getActiveItemStack() != stack ? 0.0f
|
|
|
- : (float) (stack.getUseDuration() - ent.getItemInUseCount()) / 20.0f;
|
|
|
- }
|
|
|
- });
|
|
|
- registerProperty(ModItems.sling, new ResourceLocation("pulling"), (ent, w, stack) -> {
|
|
|
- return stack != null && stack.isHandActive() && stack.getActiveItemStack() == ent ? 1.0F
|
|
|
- : 0.0F;
|
|
|
- });
|
|
|
+ ((BlockItem) stack.getItem()).getBlock().defaultBlockState(), null, null,
|
|
|
+ tintIndex), ModBlocks.tallGrass);
|
|
|
+ ItemModelsProperties.register(ModItems.sling, new ResourceLocation("pull"),
|
|
|
+ (stack, w, ent) -> {
|
|
|
+ if(ent == null) {
|
|
|
+ return 0.0F;
|
|
|
+ } else {
|
|
|
+ return ent.getUseItem() != stack ? 0.0f
|
|
|
+ : (float) (stack.getUseDuration() - ent.getUseItemRemainingTicks())
|
|
|
+ / 20.0f;
|
|
|
+ }
|
|
|
+ });
|
|
|
+ ItemModelsProperties.register(ModItems.sling, new ResourceLocation("pulling"),
|
|
|
+ (ent, w, stack) -> {
|
|
|
+ return stack != null && stack.isUsingItem() && stack.getUseItem() == ent ? 1.0F
|
|
|
+ : 0.0F;
|
|
|
+ });
|
|
|
}
|
|
|
|
|
|
@SubscribeEvent
|
|
@@ -148,16 +150,16 @@ public class Client {
|
|
|
@SuppressWarnings("")
|
|
|
private void animateTick(Block b) {
|
|
|
Minecraft mc = Minecraft.getInstance();
|
|
|
- if(mc.isGamePaused() || mc.world == null) {
|
|
|
+ if(mc.isPaused() || mc.level == null) {
|
|
|
return;
|
|
|
}
|
|
|
- int posX = MathHelper.floor(mc.player.getPosX());
|
|
|
- int posY = MathHelper.floor(mc.player.getPosY());
|
|
|
- int posZ = MathHelper.floor(mc.player.getPosZ());
|
|
|
+ int posX = MathHelper.floor(mc.player.getX());
|
|
|
+ int posY = MathHelper.floor(mc.player.getY());
|
|
|
+ int posZ = MathHelper.floor(mc.player.getZ());
|
|
|
|
|
|
boolean flag = false;
|
|
|
- if(mc.playerController.getCurrentGameType() == GameType.CREATIVE) {
|
|
|
- for(ItemStack itemstack : mc.player.getHeldEquipment()) {
|
|
|
+ if(mc.gameMode.getPlayerMode() == GameType.CREATIVE) {
|
|
|
+ for(ItemStack itemstack : mc.player.getHandSlots()) {
|
|
|
if(itemstack.getItem() == b.asItem()) {
|
|
|
flag = true;
|
|
|
break;
|
|
@@ -170,17 +172,17 @@ public class Client {
|
|
|
|
|
|
BlockPos.Mutable pos = new BlockPos.Mutable();
|
|
|
for(int j = 0; j < 667; ++j) {
|
|
|
- animateTick(mc.world, b, posX, posY, posZ, 16, pos);
|
|
|
- animateTick(mc.world, b, posX, posY, posZ, 32, pos);
|
|
|
+ animateTick(mc.level, b, posX, posY, posZ, 16, pos);
|
|
|
+ animateTick(mc.level, b, posX, posY, posZ, 32, pos);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
private void animateTick(ClientWorld w, Block b, int x, int y, int z, int offset,
|
|
|
BlockPos.Mutable pos) {
|
|
|
- x += w.rand.nextInt(offset) - w.rand.nextInt(offset);
|
|
|
- y += w.rand.nextInt(offset) - w.rand.nextInt(offset);
|
|
|
- z += w.rand.nextInt(offset) - w.rand.nextInt(offset);
|
|
|
- pos.setPos(x, y, z);
|
|
|
+ x += w.random.nextInt(offset) - w.random.nextInt(offset);
|
|
|
+ y += w.random.nextInt(offset) - w.random.nextInt(offset);
|
|
|
+ z += w.random.nextInt(offset) - w.random.nextInt(offset);
|
|
|
+ pos.set(x, y, z);
|
|
|
BlockState blockstate = w.getBlockState(pos);
|
|
|
if(blockstate.getBlock() == b) {
|
|
|
w.addParticle(ParticleTypes.BARRIER, x + 0.5, y + 0.5, z + 0.5, 0.0, 0.0, 0.0);
|
|
@@ -192,25 +194,25 @@ public class Client {
|
|
|
e.setResult(Event.Result.DENY);
|
|
|
|
|
|
Entity ent = e.getEntity();
|
|
|
- EntityRendererManager erm = Minecraft.getInstance().getRenderManager();
|
|
|
+ EntityRendererManager erm = Minecraft.getInstance().getEntityRenderDispatcher();
|
|
|
EntityRenderer<? super Entity> renderer = erm.getRenderer(ent);
|
|
|
|
|
|
if(ClientReflectionUtils.canRenderName(renderer, ent)) {
|
|
|
- double d0 = erm.squareDistanceTo(ent);
|
|
|
+ double d0 = erm.distanceToSqr(ent);
|
|
|
if(!(d0 > 4096.0D)) {
|
|
|
boolean flag = !ent.isDiscrete();
|
|
|
MatrixStack mStack = e.getMatrixStack();
|
|
|
- mStack.push();
|
|
|
- mStack.translate(0.0, ent.getHeight() + 0.5F, 0.0);
|
|
|
- mStack.rotate(erm.getCameraOrientation());
|
|
|
+ mStack.pushPose();
|
|
|
+ mStack.translate(0.0, ent.getBbHeight() + 0.5F, 0.0);
|
|
|
+ mStack.mulPose(erm.cameraOrientation());
|
|
|
mStack.scale(-0.025f, -0.025f, 0.025f);
|
|
|
|
|
|
- Matrix4f matrix4f = mStack.getLast().getMatrix();
|
|
|
+ Matrix4f matrix4f = mStack.last().pose();
|
|
|
Minecraft mc = Minecraft.getInstance();
|
|
|
- float f1 = mc.gameSettings.getTextBackgroundOpacity(0.25F);
|
|
|
+ float f1 = mc.options.getBackgroundOpacity(0.25F);
|
|
|
int j = (int) (f1 * 255.0F) << 24;
|
|
|
|
|
|
- FontRenderer fontrenderer = erm.getFontRenderer();
|
|
|
+ FontRenderer fontrenderer = erm.getFont();
|
|
|
|
|
|
ITextComponent text = ent.getCustomName();
|
|
|
if(text == null) {
|
|
@@ -218,9 +220,8 @@ public class Client {
|
|
|
}
|
|
|
String s = text.getString();
|
|
|
String[] parts = s.split("\n");
|
|
|
-
|
|
|
- int packedLight = renderer.getPackedLight(ent,
|
|
|
- Minecraft.getInstance().getRenderPartialTicks());
|
|
|
+ int packedLight = renderer.getPackedLightCoords(ent,
|
|
|
+ Minecraft.getInstance().getDeltaFrameTime());
|
|
|
|
|
|
IRenderTypeBuffer buffer = e.getRenderTypeBuffer();
|
|
|
|
|
@@ -230,17 +231,17 @@ public class Client {
|
|
|
matrix4f.translate(up);
|
|
|
continue;
|
|
|
}
|
|
|
- float f2 = -0.5f * fontrenderer.getStringWidth(line);
|
|
|
- fontrenderer.renderString(line, f2, 0.0f, 553648127, false, matrix4f, buffer,
|
|
|
+ float f2 = -0.5f * fontrenderer.width(line);
|
|
|
+ fontrenderer.drawInBatch(line, f2, 0.0f, 553648127, false, matrix4f, buffer,
|
|
|
flag, j, packedLight);
|
|
|
if(flag) {
|
|
|
- fontrenderer.renderString(line, f2, 0.0f, -1, false, matrix4f, buffer,
|
|
|
- false, 0, packedLight);
|
|
|
+ fontrenderer.drawInBatch(line, f2, 0.0f, -1, false, matrix4f, buffer, false,
|
|
|
+ 0, packedLight);
|
|
|
}
|
|
|
matrix4f.translate(up);
|
|
|
}
|
|
|
|
|
|
- mStack.pop();
|
|
|
+ mStack.popPose();
|
|
|
}
|
|
|
}
|
|
|
}
|