mirror of
https://github.com/Ellpeck/ActuallyAdditions.git
synced 2024-11-25 16:38:33 +01:00
Utils porting
This commit is contained in:
parent
24fb9a26e0
commit
3e61998ca8
10 changed files with 238 additions and 258 deletions
|
@ -9,6 +9,7 @@ import de.ellpeck.actuallyadditions.api.laser.ILaserRelayConnectionHandler;
|
|||
import de.ellpeck.actuallyadditions.api.lens.Lens;
|
||||
import de.ellpeck.actuallyadditions.api.lens.LensConversion;
|
||||
import de.ellpeck.actuallyadditions.api.recipe.*;
|
||||
import de.ellpeck.actuallyadditions.common.recipes.CrusherRecipe;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.item.Item;
|
||||
|
|
|
@ -1,41 +1,36 @@
|
|||
package de.ellpeck.actuallyadditions.common.util;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import de.ellpeck.actuallyadditions.common.ActuallyAdditions;
|
||||
import de.ellpeck.actuallyadditions.common.network.PacketHandler;
|
||||
import de.ellpeck.actuallyadditions.common.network.PacketServerToClient;
|
||||
import de.ellpeck.actuallyadditions.common.particle.ParticleBeam;
|
||||
import de.ellpeck.actuallyadditions.common.tile.TileEntityBase;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.FontRenderer;
|
||||
import net.minecraft.client.particle.Particle;
|
||||
import net.minecraft.client.renderer.BufferBuilder;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.client.renderer.GlStateManager.DestFactor;
|
||||
import net.minecraft.client.renderer.GlStateManager.SourceFactor;
|
||||
import net.minecraft.client.renderer.ItemRenderer;
|
||||
import net.minecraft.client.renderer.RenderHelper;
|
||||
import net.minecraft.client.renderer.RenderItem;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.client.renderer.block.model.IBakedModel;
|
||||
import net.minecraft.client.renderer.block.model.ItemCameraTransforms.TransformType;
|
||||
import net.minecraft.client.renderer.model.IBakedModel;
|
||||
import net.minecraft.client.renderer.model.ItemCameraTransforms;
|
||||
import net.minecraft.client.renderer.texture.TextureManager;
|
||||
import net.minecraft.client.renderer.texture.TextureMap;
|
||||
import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher;
|
||||
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
|
||||
import net.minecraft.inventory.container.PlayerContainer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import net.minecraftforge.client.ForgeHooksClient;
|
||||
import net.minecraftforge.fml.common.network.NetworkRegistry;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import net.minecraftforge.fml.network.NetworkRegistry;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
public final class AssetUtil {
|
||||
|
||||
|
@ -52,99 +47,99 @@ public final class AssetUtil {
|
|||
return getGuiLocation("booklet/" + file);
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public static void displayNameString(FontRenderer font, int xSize, int yPositionOfMachineText, String text) {
|
||||
font.drawString(text, xSize / 2 - font.getStringWidth(text) / 2, yPositionOfMachineText, StringUtil.DECIMAL_COLOR_WHITE);
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public static void displayNameString(FontRenderer font, int xSize, int yPositionOfMachineText, TileEntityBase tile) {
|
||||
displayNameString(font, xSize, yPositionOfMachineText, StringUtil.localize(tile.getNameForTranslation()));
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public static void renderBlockInWorld(Block block, int meta) {
|
||||
renderItemInWorld(new ItemStack(block, 1, meta));
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public static void renderItemInWorld(ItemStack stack) {
|
||||
if (StackUtil.isValid(stack)) {
|
||||
GlStateManager.pushMatrix();
|
||||
GlStateManager.disableLighting();
|
||||
GlStateManager.pushAttrib();
|
||||
RenderSystem.pushMatrix();
|
||||
RenderSystem.disableLighting();
|
||||
RenderSystem.pushAttrib();
|
||||
RenderHelper.enableStandardItemLighting();
|
||||
Minecraft.getMinecraft().getRenderItem().renderItem(stack, TransformType.FIXED);
|
||||
Minecraft.getInstance().getItemRenderer().renderItem(stack, ItemCameraTransforms.TransformType.FIXED);
|
||||
RenderHelper.disableStandardItemLighting();
|
||||
GlStateManager.popAttrib();
|
||||
GlStateManager.enableLighting();
|
||||
GlStateManager.popMatrix();
|
||||
RenderSystem.popAttrib();
|
||||
RenderSystem.enableLighting();
|
||||
RenderSystem.popMatrix();
|
||||
}
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public static void renderStateInWorld(IBlockState state, IBlockAccess world, BlockPos pos, float brightness) {
|
||||
Minecraft.getMinecraft().getTextureManager().bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
|
||||
IBakedModel model = Minecraft.getMinecraft().getBlockRendererDispatcher().getModelForState(state);
|
||||
GlStateManager.rotate(90.0F, 0.0F, 1.0F, 0.0F);
|
||||
int i = Minecraft.getMinecraft().getBlockColors().colorMultiplier(state, world, pos, 0);
|
||||
Minecraft.getInstance().getTextureManager().bindTexture(PlayerContainer.LOCATION_BLOCKS_TEXTURE);
|
||||
IBakedModel model = Minecraft.getInstance().getBlockRendererDispatcher().getModelForState(state);
|
||||
RenderSystem.rotate(90.0F, 0.0F, 1.0F, 0.0F);
|
||||
int i = Minecraft.getInstance().getBlockColors().colorMultiplier(state, world, pos, 0);
|
||||
|
||||
float r = (i >> 16 & 255) / 255F;
|
||||
float g = (i >> 8 & 255) / 255F;
|
||||
float b = (i & 255) / 255F;
|
||||
|
||||
Minecraft.getMinecraft().getBlockRendererDispatcher().getBlockModelRenderer().renderModelBrightnessColor(state, model, brightness, r, g, b);
|
||||
Minecraft.getInstance().getBlockRendererDispatcher().getBlockModelRenderer().renderModelBrightnessColor(state, model, brightness, r, g, b);
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public static void renderItemWithoutScrewingWithColors(ItemStack stack) {
|
||||
if (StackUtil.isValid(stack)) {
|
||||
Minecraft mc = Minecraft.getMinecraft();
|
||||
RenderItem renderer = mc.getRenderItem();
|
||||
Minecraft mc = Minecraft.getInstance();
|
||||
ItemRenderer renderer = mc.getItemRenderer();
|
||||
TextureManager manager = mc.getTextureManager();
|
||||
|
||||
IBakedModel model = renderer.getItemModelWithOverrides(stack, null, null);
|
||||
|
||||
manager.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
|
||||
manager.getTexture(TextureMap.LOCATION_BLOCKS_TEXTURE).setBlurMipmap(false, false);
|
||||
GlStateManager.enableRescaleNormal();
|
||||
GlStateManager.enableBlend();
|
||||
GlStateManager.pushMatrix();
|
||||
model = ForgeHooksClient.handleCameraTransforms(model, TransformType.FIXED, false);
|
||||
manager.bindTexture(PlayerContainer.LOCATION_BLOCKS_TEXTURE);
|
||||
manager.getTexture(PlayerContainer.LOCATION_BLOCKS_TEXTURE).setBlurMipmap(false, false);
|
||||
RenderSystem.enableRescaleNormal();
|
||||
RenderSystem.enableBlend();
|
||||
RenderSystem.pushMatrix();
|
||||
model = ForgeHooksClient.handleCameraTransforms(model, ItemCameraTransforms.TransformType.FIXED, false, false);
|
||||
renderer.renderItem(stack, model);
|
||||
GlStateManager.cullFace(GlStateManager.CullFace.BACK);
|
||||
GlStateManager.popMatrix();
|
||||
GlStateManager.disableRescaleNormal();
|
||||
GlStateManager.disableBlend();
|
||||
manager.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
|
||||
manager.getTexture(TextureMap.LOCATION_BLOCKS_TEXTURE).restoreLastBlurMipmap();
|
||||
RenderSystem.cullFace(RenderSystem.CullFace.BACK);
|
||||
RenderSystem.popMatrix();
|
||||
RenderSystem.disableRescaleNormal();
|
||||
RenderSystem.disableBlend();
|
||||
manager.bindTexture(PlayerContainer.LOCATION_BLOCKS_TEXTURE);
|
||||
manager.getTexture(PlayerContainer.LOCATION_BLOCKS_TEXTURE).restoreLastBlurMipmap();
|
||||
}
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public static void renderStackToGui(ItemStack stack, int x, int y, float scale) {
|
||||
GlStateManager.pushMatrix();
|
||||
GlStateManager.enableBlend();
|
||||
GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
|
||||
RenderSystem.pushMatrix();
|
||||
RenderSystem.enableBlend();
|
||||
RenderSystem.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
|
||||
RenderHelper.enableGUIStandardItemLighting();
|
||||
GlStateManager.enableDepth();
|
||||
GlStateManager.enableRescaleNormal();
|
||||
GlStateManager.translate(x, y, 0);
|
||||
GlStateManager.scale(scale, scale, scale);
|
||||
RenderSystem.enableDepth();
|
||||
RenderSystem.enableRescaleNormal();
|
||||
RenderSystem.translate(x, y, 0);
|
||||
RenderSystem.scale(scale, scale, scale);
|
||||
|
||||
Minecraft mc = Minecraft.getMinecraft();
|
||||
Minecraft mc = Minecraft.getInstance();
|
||||
boolean flagBefore = mc.fontRenderer.getUnicodeFlag();
|
||||
mc.fontRenderer.setUnicodeFlag(false);
|
||||
Minecraft.getMinecraft().getRenderItem().renderItemAndEffectIntoGUI(stack, 0, 0);
|
||||
Minecraft.getMinecraft().getRenderItem().renderItemOverlayIntoGUI(mc.fontRenderer, stack, 0, 0, null);
|
||||
Minecraft.getInstance().getRenderItem().renderItemAndEffectIntoGUI(stack, 0, 0);
|
||||
Minecraft.getInstance().getRenderItem().renderItemOverlayIntoGUI(mc.fontRenderer, stack, 0, 0, null);
|
||||
mc.fontRenderer.setUnicodeFlag(flagBefore);
|
||||
|
||||
RenderHelper.disableStandardItemLighting();
|
||||
GlStateManager.popMatrix();
|
||||
RenderSystem.popMatrix();
|
||||
}
|
||||
|
||||
//Copied from Gui.class and changed
|
||||
@SideOnly(Side.CLIENT)
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public static void drawHorizontalGradientRect(int left, int top, int right, int bottom, int startColor, int endColor, float zLevel) {
|
||||
float f = (startColor >> 24 & 255) / 255.0F;
|
||||
float f1 = (startColor >> 16 & 255) / 255.0F;
|
||||
|
@ -154,11 +149,11 @@ public final class AssetUtil {
|
|||
float f5 = (endColor >> 16 & 255) / 255.0F;
|
||||
float f6 = (endColor >> 8 & 255) / 255.0F;
|
||||
float f7 = (endColor & 255) / 255.0F;
|
||||
GlStateManager.disableTexture2D();
|
||||
GlStateManager.enableBlend();
|
||||
GlStateManager.disableAlpha();
|
||||
GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0);
|
||||
GlStateManager.shadeModel(7425);
|
||||
RenderSystem.disableTexture2D();
|
||||
RenderSystem.enableBlend();
|
||||
RenderSystem.disableAlpha();
|
||||
RenderSystem.tryBlendFuncSeparate(770, 771, 1, 0);
|
||||
RenderSystem.shadeModel(7425);
|
||||
Tessellator tessellator = Tessellator.getInstance();
|
||||
BufferBuilder renderer = tessellator.getBuffer();
|
||||
renderer.begin(7, DefaultVertexFormats.POSITION_COLOR);
|
||||
|
@ -167,73 +162,73 @@ public final class AssetUtil {
|
|||
renderer.pos(right, bottom, zLevel).color(f5, f6, f7, f4).endVertex();
|
||||
renderer.pos(right, top, zLevel).color(f5, f6, f7, f4).endVertex();
|
||||
tessellator.draw();
|
||||
GlStateManager.shadeModel(7424);
|
||||
GlStateManager.disableBlend();
|
||||
GlStateManager.enableAlpha();
|
||||
GlStateManager.enableTexture2D();
|
||||
RenderSystem.shadeModel(7424);
|
||||
RenderSystem.disableBlend();
|
||||
RenderSystem.enableAlpha();
|
||||
RenderSystem.enableTexture2D();
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public static void renderNameTag(String tag, double x, double y, double z) {
|
||||
FontRenderer fontrenderer = Minecraft.getMinecraft().fontRenderer;
|
||||
FontRenderer fontrenderer = Minecraft.getInstance().fontRenderer;
|
||||
float f = 1.6F;
|
||||
float f1 = 0.016666668F * f;
|
||||
GlStateManager.pushMatrix();
|
||||
GlStateManager.translate(x, y, z);
|
||||
RenderSystem.pushMatrix();
|
||||
RenderSystem.translate(x, y, z);
|
||||
GL11.glNormal3f(0.0F, 1.0F, 0.0F);
|
||||
GlStateManager.rotate(-Minecraft.getMinecraft().getRenderManager().playerViewY, 0.0F, 1.0F, 0.0F);
|
||||
GlStateManager.rotate(Minecraft.getMinecraft().getRenderManager().playerViewX, 1.0F, 0.0F, 0.0F);
|
||||
GlStateManager.scale(-f1, -f1, f1);
|
||||
GlStateManager.disableLighting();
|
||||
GlStateManager.depthMask(false);
|
||||
GlStateManager.disableDepth();
|
||||
GlStateManager.enableBlend();
|
||||
GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0);
|
||||
RenderSystem.rotate(-Minecraft.getInstance().getRenderManager().playerViewY, 0.0F, 1.0F, 0.0F);
|
||||
RenderSystem.rotate(Minecraft.getInstance().getRenderManager().playerViewX, 1.0F, 0.0F, 0.0F);
|
||||
RenderSystem.scale(-f1, -f1, f1);
|
||||
RenderSystem.disableLighting();
|
||||
RenderSystem.depthMask(false);
|
||||
RenderSystem.disableDepth();
|
||||
RenderSystem.enableBlend();
|
||||
RenderSystem.tryBlendFuncSeparate(770, 771, 1, 0);
|
||||
Tessellator tessellator = Tessellator.getInstance();
|
||||
BufferBuilder renderer = tessellator.getBuffer();
|
||||
int i = 0;
|
||||
int j = fontrenderer.getStringWidth(tag) / 2;
|
||||
GlStateManager.disableTexture2D();
|
||||
RenderSystem.disableTexture2D();
|
||||
renderer.begin(7, DefaultVertexFormats.POSITION_COLOR);
|
||||
renderer.pos(-j - 1, -1 + i, 0.0D).color(0.0F, 0.0F, 0.0F, 0.25F).endVertex();
|
||||
renderer.pos(-j - 1, 8 + i, 0.0D).color(0.0F, 0.0F, 0.0F, 0.25F).endVertex();
|
||||
renderer.pos(j + 1, 8 + i, 0.0D).color(0.0F, 0.0F, 0.0F, 0.25F).endVertex();
|
||||
renderer.pos(j + 1, -1 + i, 0.0D).color(0.0F, 0.0F, 0.0F, 0.25F).endVertex();
|
||||
tessellator.draw();
|
||||
GlStateManager.enableTexture2D();
|
||||
RenderSystem.enableTexture2D();
|
||||
fontrenderer.drawString(tag, -fontrenderer.getStringWidth(tag) / 2, i, 553648127);
|
||||
GlStateManager.enableDepth();
|
||||
GlStateManager.depthMask(true);
|
||||
RenderSystem.enableDepth();
|
||||
RenderSystem.depthMask(true);
|
||||
fontrenderer.drawString(tag, -fontrenderer.getStringWidth(tag) / 2, i, -1);
|
||||
GlStateManager.enableLighting();
|
||||
GlStateManager.disableBlend();
|
||||
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
GlStateManager.popMatrix();
|
||||
RenderSystem.enableLighting();
|
||||
RenderSystem.disableBlend();
|
||||
RenderSystem.color(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
RenderSystem.popMatrix();
|
||||
}
|
||||
|
||||
public static void spawnLaserWithTimeServer(World world, double startX, double startY, double startZ, double endX, double endY, double endZ, float[] color, int maxAge, double rotationTime, float size, float alpha) {
|
||||
if (!world.isRemote) {
|
||||
NBTTagCompound data = new NBTTagCompound();
|
||||
data.setDouble("StartX", startX);
|
||||
data.setDouble("StartY", startY);
|
||||
data.setDouble("StartZ", startZ);
|
||||
data.setDouble("EndX", endX);
|
||||
data.setDouble("EndY", endY);
|
||||
data.setDouble("EndZ", endZ);
|
||||
data.setFloat("Color1", color[0]);
|
||||
data.setFloat("Color2", color[1]);
|
||||
data.setFloat("Color3", color[2]);
|
||||
data.setDouble("RotationTime", rotationTime);
|
||||
data.setFloat("Size", size);
|
||||
data.setInteger("MaxAge", maxAge);
|
||||
data.setFloat("Alpha", alpha);
|
||||
CompoundNBT data = new CompoundNBT();
|
||||
data.putDouble("StartX", startX);
|
||||
data.putDouble("StartY", startY);
|
||||
data.putDouble("StartZ", startZ);
|
||||
data.putDouble("EndX", endX);
|
||||
data.putDouble("EndY", endY);
|
||||
data.putDouble("EndZ", endZ);
|
||||
data.putFloat("Color1", color[0]);
|
||||
data.putFloat("Color2", color[1]);
|
||||
data.putFloat("Color3", color[2]);
|
||||
data.putDouble("RotationTime", rotationTime);
|
||||
data.putFloat("Size", size);
|
||||
data.putInt("MaxAge", maxAge);
|
||||
data.putFloat("Alpha", alpha);
|
||||
PacketHandler.theNetwork.sendToAllAround(new PacketServerToClient(data, PacketHandler.LASER_HANDLER), new NetworkRegistry.TargetPoint(world.provider.getDimension(), startX, startY, startZ, 96));
|
||||
}
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public static void spawnLaserWithTimeClient(double startX, double startY, double startZ, double endX, double endY, double endZ, float[] color, int maxAge, double rotationTime, float size, float alpha) {
|
||||
Minecraft mc = Minecraft.getMinecraft();
|
||||
Minecraft mc = Minecraft.getInstance();
|
||||
|
||||
if (mc.player.getDistance(startX, startY, startZ) <= 64 || mc.player.getDistance(endX, endY, endZ) <= 64) {
|
||||
Particle fx = new ParticleBeam(mc.world, startX, startY, startZ, endX, endY, endZ, color, maxAge, rotationTime, size, alpha);
|
||||
|
@ -243,11 +238,11 @@ public final class AssetUtil {
|
|||
|
||||
//Thanks to feldim2425 for this.
|
||||
//I can't do rendering code. Ever.
|
||||
@SideOnly(Side.CLIENT)
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public static void renderLaser(double firstX, double firstY, double firstZ, double secondX, double secondY, double secondZ, double rotationTime, float alpha, double beamWidth, float[] color) {
|
||||
Tessellator tessy = Tessellator.getInstance();
|
||||
BufferBuilder render = tessy.getBuffer();
|
||||
World world = Minecraft.getMinecraft().world;
|
||||
World world = Minecraft.getInstance().world;
|
||||
|
||||
float r = color[0];
|
||||
float g = color[1];
|
||||
|
@ -263,22 +258,22 @@ public final class AssetUtil {
|
|||
|
||||
double length = combinedVec.length();
|
||||
|
||||
GlStateManager.pushMatrix();
|
||||
RenderSystem.pushMatrix();
|
||||
|
||||
GlStateManager.disableLighting();
|
||||
GlStateManager.enableBlend();
|
||||
GlStateManager.blendFunc(SourceFactor.SRC_ALPHA, DestFactor.ONE);
|
||||
RenderSystem.disableLighting();
|
||||
RenderSystem.enableBlend();
|
||||
RenderSystem.blendFunc(SourceFactor.SRC_ALPHA, DestFactor.ONE);
|
||||
int func = GL11.glGetInteger(GL11.GL_ALPHA_TEST_FUNC);
|
||||
float ref = GL11.glGetFloat(GL11.GL_ALPHA_TEST_REF);
|
||||
GlStateManager.alphaFunc(GL11.GL_ALWAYS, 0);
|
||||
GlStateManager.translate(firstX - TileEntityRendererDispatcher.staticPlayerX, firstY - TileEntityRendererDispatcher.staticPlayerY, firstZ - TileEntityRendererDispatcher.staticPlayerZ);
|
||||
GlStateManager.rotate((float) (180 * yaw / Math.PI), 0, 1, 0);
|
||||
GlStateManager.rotate((float) (180 * pitch / Math.PI), 0, 0, 1);
|
||||
GlStateManager.rotate((float) rot, 1, 0, 0);
|
||||
RenderSystem.alphaFunc(GL11.GL_ALWAYS, 0);
|
||||
RenderSystem.translate(firstX - TileEntityRendererDispatcher.staticPlayerX, firstY - TileEntityRendererDispatcher.staticPlayerY, firstZ - TileEntityRendererDispatcher.staticPlayerZ);
|
||||
RenderSystem.rotate((float) (180 * yaw / Math.PI), 0, 1, 0);
|
||||
RenderSystem.rotate((float) (180 * pitch / Math.PI), 0, 0, 1);
|
||||
RenderSystem.rotate((float) rot, 1, 0, 0);
|
||||
|
||||
/*if(r != r2 || g != g2 || b != b2){
|
||||
render.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX_COLOR);
|
||||
Minecraft.getMinecraft().renderEngine.bindTexture(ClientUtil.LIGHT_BEAM_GRADIENT);
|
||||
Minecraft.getInstance().renderEngine.bindTexture(ClientUtil.LIGHT_BEAM_GRADIENT);
|
||||
|
||||
render.pos(length, -beamWidth, beamWidth).tex(0, 0).color(r, g, b, alpha).endVertex();
|
||||
render.pos(length, beamWidth, beamWidth).tex(0, 1).color(r, g, b, alpha).endVertex();
|
||||
|
@ -322,7 +317,7 @@ public final class AssetUtil {
|
|||
tessy.draw();
|
||||
}
|
||||
else{*/
|
||||
GlStateManager.disableTexture2D();
|
||||
RenderSystem.disableTexture2D();
|
||||
render.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX_LMAP_COLOR);
|
||||
for (double i = 0; i < 4; i++) {
|
||||
double width = beamWidth * (i / 4.0);
|
||||
|
@ -348,14 +343,14 @@ public final class AssetUtil {
|
|||
}
|
||||
tessy.draw();
|
||||
|
||||
GlStateManager.enableTexture2D();
|
||||
RenderSystem.enableTexture2D();
|
||||
//}
|
||||
|
||||
GlStateManager.alphaFunc(func, ref);
|
||||
GlStateManager.blendFunc(SourceFactor.SRC_ALPHA, DestFactor.ONE_MINUS_SRC_ALPHA);
|
||||
GlStateManager.disableBlend();
|
||||
GlStateManager.enableLighting();
|
||||
GlStateManager.popMatrix();
|
||||
RenderSystem.alphaFunc(func, ref);
|
||||
RenderSystem.blendFunc(SourceFactor.SRC_ALPHA, DestFactor.ONE_MINUS_SRC_ALPHA);
|
||||
RenderSystem.disableBlend();
|
||||
RenderSystem.enableLighting();
|
||||
RenderSystem.popMatrix();
|
||||
}
|
||||
|
||||
public static float[] getWheelColor(float pos) {
|
||||
|
|
|
@ -12,6 +12,7 @@ import net.minecraft.util.math.MathHelper;
|
|||
import net.minecraft.world.storage.loot.LootContext;
|
||||
import net.minecraft.world.storage.loot.LootTable;
|
||||
import net.minecraftforge.fml.common.FMLCommonHandler;
|
||||
import net.minecraftforge.fml.loading.FMLLoader;
|
||||
import net.minecraftforge.items.IItemHandlerModifiable;
|
||||
|
||||
//This is stuff copied from somewhere in vanilla and changed so that it works properly
|
||||
|
@ -52,7 +53,7 @@ public final class AwfulUtil {
|
|||
while (someInt > 0 && list.size() > 0) {
|
||||
ItemStack itemstack2 = list.remove(MathHelper.getInt(rand, 0, list.size() - 1));
|
||||
int i = MathHelper.getInt(rand, 1, itemstack2.getCount() / 2);
|
||||
ItemStack itemstack1 = itemstack2.splitStack(i);
|
||||
ItemStack itemstack1 = itemstack2.split(i);
|
||||
|
||||
if (itemstack2.getCount() > 1 && rand.nextBoolean()) {
|
||||
list.add(itemstack2);
|
||||
|
@ -90,7 +91,7 @@ public final class AwfulUtil {
|
|||
for (Object k : stuff) {
|
||||
error += "\n" + i++ + ": " + (k == null ? "null" : k.getClass().getSimpleName() + " <- CLASS | INSTANCE -> " + k.toString() + ", ");
|
||||
}
|
||||
error += "\n" + "The current side is: " + FMLCommonHandler.instance().getEffectiveSide();
|
||||
error += "\n" + "The current side is: " + FMLLoader.getDist();
|
||||
error += "\n" + "Report this to https://github.com/Ellpeck/ActuallyAdditions/issues";
|
||||
throw new IllegalStateException(error);
|
||||
}
|
||||
|
|
|
@ -1,22 +1,17 @@
|
|||
package de.ellpeck.actuallyadditions.common.util;
|
||||
|
||||
import net.minecraft.enchantment.Enchantment;
|
||||
import net.minecraft.enchantment.EnchantmentHelper;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import de.ellpeck.actuallyadditions.common.ActuallyAdditions;
|
||||
import de.ellpeck.actuallyadditions.common.RegistryHandler;
|
||||
import de.ellpeck.actuallyadditions.common.creative.CreativeTab;
|
||||
import de.ellpeck.actuallyadditions.common.util.compat.IMCHandler;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.enchantment.Enchantment;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.util.EnumHand;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.fml.common.registry.ForgeRegistries;
|
||||
import java.util.Map;
|
||||
|
||||
public final class ItemUtil {
|
||||
|
||||
|
@ -24,40 +19,40 @@ public final class ItemUtil {
|
|||
return ForgeRegistries.ITEMS.getValue(new ResourceLocation(name));
|
||||
}
|
||||
|
||||
@Deprecated // canitzp: should be removed
|
||||
public static void registerBlock(Block block, BlockItemBase itemBlock, String name, boolean addTab) {
|
||||
block.setTranslationKey(ActuallyAdditions.MODID + "." + name);
|
||||
// @Deprecated // canitzp: should be removed
|
||||
// public static void registerBlock(Block block, BlockAtomicReconstructor.BlockItem itemBlock, String name, boolean addTab) {
|
||||
// block.setTranslationKey(ActuallyAdditions.MODID + "." + name);
|
||||
//
|
||||
// block.setRegistryName(ActuallyAdditions.MODID, name);
|
||||
// RegistryHandler.BLOCKS_TO_REGISTER.add(block);
|
||||
//
|
||||
// itemBlock.setRegistryName(block.getRegistryName());
|
||||
// RegistryHandler.ITEMS_TO_REGISTER.add(itemBlock);
|
||||
//
|
||||
// block.setCreativeTab(addTab ? CreativeTab.INSTANCE : null);
|
||||
//
|
||||
// IMCHandler.doBlockIMC(block);
|
||||
//
|
||||
// if (block instanceof IColorProvidingBlock) {
|
||||
// ActuallyAdditions.PROXY.addColoredBlock(block);
|
||||
// }
|
||||
// }
|
||||
|
||||
block.setRegistryName(ActuallyAdditions.MODID, name);
|
||||
RegistryHandler.BLOCKS_TO_REGISTER.add(block);
|
||||
|
||||
itemBlock.setRegistryName(block.getRegistryName());
|
||||
RegistryHandler.ITEMS_TO_REGISTER.add(itemBlock);
|
||||
|
||||
block.setCreativeTab(addTab ? CreativeTab.INSTANCE : null);
|
||||
|
||||
IMCHandler.doBlockIMC(block);
|
||||
|
||||
if (block instanceof IColorProvidingBlock) {
|
||||
ActuallyAdditions.PROXY.addColoredBlock(block);
|
||||
}
|
||||
}
|
||||
|
||||
@Deprecated // canitzp: should be removed
|
||||
public static void registerItem(Item item, String name, boolean addTab) {
|
||||
item.setTranslationKey(ActuallyAdditions.MODID + "." + name);
|
||||
|
||||
item.setRegistryName(ActuallyAdditions.MODID, name);
|
||||
RegistryHandler.ITEMS_TO_REGISTER.add(item);
|
||||
|
||||
item.setCreativeTab(addTab ? CreativeTab.INSTANCE : null);
|
||||
|
||||
IMCHandler.doItemIMC(item);
|
||||
|
||||
if (item instanceof IColorProvidingItem) {
|
||||
ActuallyAdditions.PROXY.addColoredItem(item);
|
||||
}
|
||||
}
|
||||
// @Deprecated // canitzp: should be removed
|
||||
// public static void registerItem(Item item, String name, boolean addTab) {
|
||||
// item.setTranslationKey(ActuallyAdditions.MODID + "." + name);
|
||||
//
|
||||
// item.setRegistryName(ActuallyAdditions.MODID, name);
|
||||
// RegistryHandler.ITEMS_TO_REGISTER.add(item);
|
||||
//
|
||||
// item.setCreativeTab(addTab ? CreativeTab.INSTANCE : null);
|
||||
//
|
||||
// IMCHandler.doItemIMC(item);
|
||||
//
|
||||
// if (item instanceof IColorProvidingItem) {
|
||||
// ActuallyAdditions.PROXY.addColoredItem(item);
|
||||
// }
|
||||
// }
|
||||
|
||||
public static boolean contains(ItemStack[] array, ItemStack stack, boolean checkWildcard) {
|
||||
return getPlaceAt(array, stack, checkWildcard) != -1;
|
||||
|
@ -77,7 +72,8 @@ public final class ItemUtil {
|
|||
}
|
||||
|
||||
public static boolean areItemsEqual(ItemStack stack1, ItemStack stack2, boolean checkWildcard) {
|
||||
return StackUtil.isValid(stack1) && StackUtil.isValid(stack2) && (stack1.isItemEqual(stack2) || checkWildcard && stack1.getItem() == stack2.getItem() && (stack1.getItemDamage() == Util.WILDCARD || stack2.getItemDamage() == Util.WILDCARD));
|
||||
// todo: fix wildcard
|
||||
return StackUtil.isValid(stack1) && StackUtil.isValid(stack2) && (stack1.isItemEqual(stack2) || checkWildcard && stack1.getItem() == stack2.getItem() && (stack1.getDamage() == Util.WILDCARD || stack2.getDamage() == Util.WILDCARD));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -94,29 +90,14 @@ public final class ItemUtil {
|
|||
}
|
||||
|
||||
public static boolean hasEnchantment(ItemStack stack, Enchantment e) {
|
||||
NBTTagList ench = stack.getEnchantmentTagList();
|
||||
if (ench != null) {
|
||||
for (int i = 0; i < ench.tagCount(); i++) {
|
||||
short id = ench.getCompoundTagAt(i).getShort("id");
|
||||
if (id == Enchantment.getEnchantmentID(e)) { return true; }
|
||||
}
|
||||
}
|
||||
return false;
|
||||
return EnchantmentHelper.getEnchantments(stack).containsKey(e);
|
||||
}
|
||||
|
||||
public static void removeEnchantment(ItemStack stack, Enchantment e) {
|
||||
NBTTagList ench = stack.getEnchantmentTagList();
|
||||
if (ench != null) {
|
||||
for (int i = 0; i < ench.tagCount(); i++) {
|
||||
short id = ench.getCompoundTagAt(i).getShort("id");
|
||||
if (id == Enchantment.getEnchantmentID(e)) {
|
||||
ench.removeTag(i);
|
||||
}
|
||||
}
|
||||
if (ench.isEmpty() && stack.hasTagCompound()) {
|
||||
stack.getTagCompound().removeTag("ench");
|
||||
}
|
||||
}
|
||||
Map<Enchantment, Integer> enchantments = EnchantmentHelper.getEnchantments(stack);
|
||||
enchantments.remove(e);
|
||||
|
||||
EnchantmentHelper.setEnchantments(enchantments, stack);
|
||||
}
|
||||
|
||||
public static boolean canBeStacked(ItemStack stack1, ItemStack stack2) {
|
||||
|
@ -124,19 +105,15 @@ public final class ItemUtil {
|
|||
}
|
||||
|
||||
public static boolean isEnabled(ItemStack stack) {
|
||||
return stack.hasTagCompound() && stack.getTagCompound().getBoolean("IsEnabled");
|
||||
return stack.getOrCreateTag().getBoolean("IsEnabled");
|
||||
}
|
||||
|
||||
public static void changeEnabled(EntityPlayer player, EnumHand hand) {
|
||||
public static void changeEnabled(PlayerEntity player, Hand hand) {
|
||||
changeEnabled(player.getHeldItem(hand));
|
||||
}
|
||||
|
||||
public static void changeEnabled(ItemStack stack) {
|
||||
if (!stack.hasTagCompound()) {
|
||||
stack.setTagCompound(new NBTTagCompound());
|
||||
}
|
||||
|
||||
boolean isEnabled = isEnabled(stack);
|
||||
stack.getTagCompound().setBoolean("IsEnabled", !isEnabled);
|
||||
stack.getOrCreateTag().putBoolean("IsEnabled", !isEnabled);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,13 +1,14 @@
|
|||
package de.ellpeck.actuallyadditions.common.util;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI;
|
||||
import de.ellpeck.actuallyadditions.api.recipe.EmpowererRecipe;
|
||||
import de.ellpeck.actuallyadditions.api.recipe.LensConversionRecipe;
|
||||
import de.ellpeck.actuallyadditions.common.recipes.CrusherRecipe;
|
||||
import de.ellpeck.actuallyadditions.common.util.crafting.RecipeHandler;
|
||||
import net.minecraft.item.crafting.IRecipe;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public final class RecipeUtil {
|
||||
|
||||
public static LensConversionRecipe lastReconstructorRecipe() {
|
||||
|
|
|
@ -1,20 +1,17 @@
|
|||
package de.ellpeck.actuallyadditions.common.util;
|
||||
|
||||
import com.google.common.base.MoreObjects;
|
||||
import com.google.common.base.Preconditions;
|
||||
import net.minecraftforge.fml.loading.FMLEnvironment;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.StringJoiner;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import com.google.common.base.MoreObjects;
|
||||
import com.google.common.base.Preconditions;
|
||||
|
||||
import net.minecraftforge.fml.relauncher.FMLLaunchHandler;
|
||||
|
||||
public class RefHelp {
|
||||
|
||||
public static class UnableToFindMethodException extends RuntimeException {
|
||||
|
@ -86,7 +83,7 @@ public class RefHelp {
|
|||
Preconditions.checkNotNull(clazz);
|
||||
Preconditions.checkArgument(StringUtils.isNotEmpty(fieldName), "Field name cannot be empty");
|
||||
|
||||
String nameToFind = FMLLaunchHandler.isDeobfuscatedEnvironment() ? fieldName : MoreObjects.firstNonNull(fieldObfName, fieldName);
|
||||
String nameToFind = !FMLEnvironment.production ? fieldName : MoreObjects.firstNonNull(fieldObfName, fieldName);
|
||||
|
||||
try {
|
||||
Field f = clazz.getDeclaredField(nameToFind);
|
||||
|
@ -184,7 +181,7 @@ public class RefHelp {
|
|||
Preconditions.checkNotNull(clazz);
|
||||
Preconditions.checkArgument(StringUtils.isNotEmpty(methodName), "Method name cannot be empty");
|
||||
|
||||
String nameToFind = FMLLaunchHandler.isDeobfuscatedEnvironment() ? methodName : MoreObjects.firstNonNull(methodObfName, methodName);
|
||||
String nameToFind = !FMLEnvironment.production ? methodName : MoreObjects.firstNonNull(methodObfName, methodName);
|
||||
|
||||
try {
|
||||
Method m = clazz.getDeclaredMethod(nameToFind, parameterTypes);
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
package de.ellpeck.actuallyadditions.common.util;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import org.cyclops.commoncapabilities.api.capability.itemhandler.ISlotlessItemHandler;
|
||||
|
||||
import de.ellpeck.actuallyadditions.api.misc.IDisableableItem;
|
||||
import de.ellpeck.actuallyadditions.common.ActuallyAdditions;
|
||||
import de.ellpeck.actuallyadditions.common.util.compat.SlotlessableItemHandlerWrapper;
|
||||
|
@ -13,6 +8,9 @@ import net.minecraft.item.ItemStack;
|
|||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
public final class StackUtil {
|
||||
|
||||
/**
|
||||
|
@ -183,10 +181,11 @@ public final class StackUtil {
|
|||
|
||||
if (ActuallyAdditions.commonCapsLoaded) {
|
||||
Object handler = wrapper.getSlotlessHandler();
|
||||
if (handler instanceof ISlotlessItemHandler) {
|
||||
remain = ((ISlotlessItemHandler) handler).insertItem(remain, simulate);
|
||||
if (!ItemStack.areItemStacksEqual(remain, stack)) return remain;
|
||||
}
|
||||
// todo: reimplement?
|
||||
// if (handler instanceof ISlotlessItemHandler) {
|
||||
// remain = ((ISlotlessItemHandler) handler).insertItem(remain, simulate);
|
||||
// if (!ItemStack.areItemStacksEqual(remain, stack)) return remain;
|
||||
// }
|
||||
}
|
||||
|
||||
IItemHandler handler = wrapper.getNormalHandler();
|
||||
|
|
|
@ -1,17 +1,17 @@
|
|||
package de.ellpeck.actuallyadditions.common.util;
|
||||
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import de.ellpeck.actuallyadditions.common.ActuallyAdditions;
|
||||
import net.minecraft.client.gui.FontRenderer;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.util.text.LanguageMap;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.List;
|
||||
|
||||
import de.ellpeck.actuallyadditions.common.ActuallyAdditions;
|
||||
import net.minecraft.client.gui.FontRenderer;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.util.text.translation.LanguageMap;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
public final class StringUtil {
|
||||
|
||||
public static final int DECIMAL_COLOR_WHITE = 16777215;
|
||||
|
@ -22,7 +22,7 @@ public final class StringUtil {
|
|||
/**
|
||||
* Localizes a given String
|
||||
*/
|
||||
@SideOnly(Side.CLIENT)
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public static String localize(String text) {
|
||||
return I18n.format(text);
|
||||
}
|
||||
|
@ -30,39 +30,50 @@ public final class StringUtil {
|
|||
/**
|
||||
* Localizes a given formatted String with the given Replacements
|
||||
*/
|
||||
@SideOnly(Side.CLIENT)
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public static String localizeFormatted(String text, Object... replace) {
|
||||
return I18n.format(text, replace);
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation") //TODO: delete this shit and move ItemPotionRing's getItemStackDisplayName into getUnlocalizedName
|
||||
public static String localizeIllegallyOnTheServerDontUseMePls(String langKey) {
|
||||
return net.minecraft.util.text.translation.I18n.translateToLocal(langKey);
|
||||
}
|
||||
// @SuppressWarnings("deprecation") //TODO: delete this shit and move ItemPotionRing's getItemStackDisplayName into getUnlocalizedName
|
||||
// public static String localizeIllegallyOnTheServerDontUseMePls(String langKey) {
|
||||
// return net.minecraft.util.text.translation.I18n.translateToLocal(langKey);
|
||||
// }
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public static void drawSplitString(FontRenderer renderer, String strg, int x, int y, int width, int color, boolean shadow) {
|
||||
List<String> list = renderer.listFormattedStringToWidth(strg, width);
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
String s1 = list.get(i);
|
||||
renderer.drawString(s1, x, y + i * renderer.FONT_HEIGHT, color, shadow);
|
||||
if (shadow) {
|
||||
renderer.drawStringWithShadow(s1, x, y + i * renderer.FONT_HEIGHT, color);
|
||||
}
|
||||
else {
|
||||
renderer.drawString(s1, x, y + i * renderer.FONT_HEIGHT, color);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public static void renderScaledAsciiString(FontRenderer font, String text, float x, float y, int color, boolean shadow, float scale) {
|
||||
GlStateManager.pushMatrix();
|
||||
GlStateManager.scale(scale, scale, scale);
|
||||
boolean oldUnicode = font.getUnicodeFlag();
|
||||
font.setUnicodeFlag(false);
|
||||
RenderSystem.pushMatrix();
|
||||
RenderSystem.scalef(scale, scale, scale);
|
||||
// todo: validate
|
||||
// boolean oldUnicode = font.getUnicodeFlag();
|
||||
// font.setUnicodeFlag(false);
|
||||
|
||||
font.drawString(text, x / scale, y / scale, color, shadow);
|
||||
|
||||
font.setUnicodeFlag(oldUnicode);
|
||||
GlStateManager.popMatrix();
|
||||
if (shadow) {
|
||||
font.drawStringWithShadow(text, x / scale, y / scale, color);
|
||||
}
|
||||
else {
|
||||
font.drawString(text, x / scale, y / scale, color);
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
// font.setUnicodeFlag(oldUnicode);
|
||||
RenderSystem.popMatrix();
|
||||
}
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public static void renderSplitScaledAsciiString(FontRenderer font, String text, int x, int y, int color, boolean shadow, float scale, int length) {
|
||||
List<String> lines = font.listFormattedStringToWidth(text, (int) (length / scale));
|
||||
for (int i = 0; i < lines.size(); i++) {
|
||||
|
|
|
@ -24,7 +24,7 @@ public final class Util {
|
|||
}
|
||||
|
||||
public static boolean isDevVersion() {
|
||||
return ActuallyAdditions.VERSION.equals("@VERSION@");
|
||||
return false; // ActuallyAdditions.VERSION.equals("@VERSION@"); //todo: reimplement
|
||||
}
|
||||
|
||||
@Deprecated // canitzp: should not be used and removed asap
|
||||
|
@ -33,7 +33,7 @@ public final class Util {
|
|||
}
|
||||
|
||||
private static String[] splitVersion() {
|
||||
return ActuallyAdditions.VERSION.split("-");
|
||||
return "1-1".split("-"); // ActuallyAdditions.VERSION.split("-"); todo: implement
|
||||
}
|
||||
|
||||
public static String getMcVersion() {
|
||||
|
|
|
@ -1,24 +1,22 @@
|
|||
package de.ellpeck.actuallyadditions.common.util;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.server.management.PlayerChunkMapEntry;
|
||||
import net.minecraft.entity.player.ServerPlayerEntity;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.WorldServer;
|
||||
import net.minecraft.world.server.ServerWorld;
|
||||
|
||||
public final class VanillaPacketDispatcher {
|
||||
|
||||
//Don't call from the client.
|
||||
public static void dispatchTEToNearbyPlayers(TileEntity tile) {
|
||||
WorldServer world = (WorldServer) tile.getWorld();
|
||||
ServerWorld world = (ServerWorld) tile.getWorld();
|
||||
PlayerChunkMapEntry entry = world.getPlayerChunkMap().getEntry(tile.getPos().getX() >> 4, tile.getPos().getZ() >> 4);
|
||||
|
||||
if (entry == null) return;
|
||||
|
||||
for (EntityPlayerMP player : entry.getWatchingPlayers())
|
||||
for (ServerPlayerEntity player : entry.getWatchingPlayers())
|
||||
player.connection.sendPacket(tile.getUpdatePacket());
|
||||
|
||||
}
|
||||
|
||||
public static void dispatchTEToNearbyPlayers(World world, BlockPos pos) {
|
||||
|
|
Loading…
Reference in a new issue