mirror of
https://github.com/GTNewHorizons/Botania.git
synced 2026-11-19 03:39:17 +00:00
Tweak multiblocks a bit
This commit is contained in:
1 parent
0a7268fc98
commit
9cd7a4a0d5
6 files changed
+33
-40
No files matched your search
@@ -10,14 +10,12 @@
|
||||
*/
|
||||
package vazkii.botania.api.lexicon.multiblock;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.*;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import vazkii.botania.api.lexicon.multiblock.component.MultiblockComponent;
|
||||
|
||||
/**
|
||||
@@ -125,17 +123,21 @@ public class Multiblock {
|
||||
* to render this multiblock in the world relevant to the 4 cardinal
|
||||
* orientations.
|
||||
*/
|
||||
public Multiblock[] createRotations() {
|
||||
Multiblock[] blocks = new Multiblock[4];
|
||||
blocks[0] = this;
|
||||
blocks[1] = blocks[0].copy();
|
||||
blocks[1].rotate(Math.PI / 2);
|
||||
blocks[2] = blocks[1].copy();
|
||||
blocks[2].rotate(Math.PI / 2);
|
||||
blocks[3] = blocks[2].copy();
|
||||
blocks[3].rotate(Math.PI / 2);
|
||||
public Map<EnumFacing, Multiblock> createRotations() {
|
||||
Map<EnumFacing, Multiblock> ret = new EnumMap<EnumFacing, Multiblock>(EnumFacing.class);
|
||||
|
||||
return blocks;
|
||||
ret.put(EnumFacing.SOUTH, this);
|
||||
|
||||
ret.put(EnumFacing.WEST, ret.get(EnumFacing.SOUTH).copy());
|
||||
ret.get(EnumFacing.WEST).rotate(Math.PI / 2);
|
||||
|
||||
ret.put(EnumFacing.NORTH, ret.get(EnumFacing.WEST).copy());
|
||||
ret.get(EnumFacing.NORTH).rotate(Math.PI / 2);
|
||||
|
||||
ret.put(EnumFacing.EAST, ret.get(EnumFacing.NORTH).copy());
|
||||
ret.get(EnumFacing.EAST).rotate(Math.PI / 2);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -11,33 +11,28 @@
|
||||
package vazkii.botania.api.lexicon.multiblock;
|
||||
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.MathHelper;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* A set of Multiblock objects for various rotations.
|
||||
*/
|
||||
public class MultiblockSet {
|
||||
|
||||
private final Multiblock[] mbs;
|
||||
|
||||
public MultiblockSet(Multiblock[] mbs) {
|
||||
this.mbs = mbs;
|
||||
}
|
||||
private final Map<EnumFacing, Multiblock> mbs;
|
||||
|
||||
public MultiblockSet(Multiblock mb) {
|
||||
this(mb.createRotations());
|
||||
mbs = Collections.unmodifiableMap(mb.createRotations());
|
||||
}
|
||||
|
||||
public Multiblock getForEntity(Entity e) {
|
||||
return getForRotation(e.rotationYaw);
|
||||
return getForFacing(e.getHorizontalFacing());
|
||||
}
|
||||
|
||||
public Multiblock getForRotation(double rotation) {
|
||||
int facing = MathHelper.floor_double(rotation * 4.0 / 360.0 + 0.5) & 3;
|
||||
return getForIndex(facing);
|
||||
}
|
||||
|
||||
public Multiblock getForIndex(int index) {
|
||||
return mbs[Math.min(mbs.length - 1, index)];
|
||||
public Multiblock getForFacing(EnumFacing facing) {
|
||||
return mbs.get(facing);
|
||||
}
|
||||
}
|
||||
@@ -25,8 +25,8 @@ public class FlowerComponent extends ColorSwitchingComponent {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean matches(World world, int x, int y, int z) {
|
||||
return BotaniaAPI.internalHandler.isBotaniaFlower(, world, , x);
|
||||
public boolean matches(World world, BlockPos pos) {
|
||||
return BotaniaAPI.internalHandler.isBotaniaFlower(world, pos);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -17,12 +17,7 @@ import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.client.renderer.entity.RenderManager;
|
||||
import net.minecraft.client.renderer.texture.TextureMap;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.util.ChatComponentTranslation;
|
||||
import net.minecraft.util.ChatStyle;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.util.EnumChatFormatting;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.util.MovingObjectPosition;
|
||||
import net.minecraft.util.*;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.client.event.RenderWorldLastEvent;
|
||||
@@ -79,7 +74,7 @@ public final class MultiblockRenderHandler {
|
||||
int anchorZ = anchor != null ? anchor.posZ : src.blockZ;
|
||||
|
||||
rendering = true;
|
||||
Multiblock mb = anchor != null ? currentMultiblock.getForIndex(angle) : currentMultiblock.getForEntity(player);
|
||||
Multiblock mb = anchor != null ? currentMultiblock.getForFacing(EnumFacing.getHorizontal(angle)) : currentMultiblock.getForEntity(player);
|
||||
boolean didAny = false;
|
||||
|
||||
blockAccess.update(player.worldObj, mb, anchorX, anchorY, anchorZ);
|
||||
|
||||
@@ -28,6 +28,7 @@ import net.minecraft.item.ItemRecord;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntitySkull;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.MovingObjectPosition;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.WorldSettings.GameType;
|
||||
@@ -427,7 +428,7 @@ public class ClientProxy extends CommonProxy {
|
||||
public void removeSextantMultiblock() {
|
||||
MultiblockSet set = MultiblockRenderHandler.currentMultiblock;
|
||||
if(set != null) {
|
||||
Multiblock mb = set.getForIndex(0);
|
||||
Multiblock mb = set.getForFacing(EnumFacing.SOUTH);
|
||||
if(mb instanceof MultiblockSextant)
|
||||
MultiblockRenderHandler.setMultiblock(null);
|
||||
}
|
||||
|
||||
@@ -18,11 +18,11 @@ import net.minecraft.client.gui.FontRenderer;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.client.renderer.RenderHelper;
|
||||
import net.minecraft.client.renderer.entity.RenderItem;
|
||||
import net.minecraft.client.renderer.texture.TextureManager;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumChatFormatting;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.StatCollector;
|
||||
|
||||
@@ -49,7 +49,7 @@ public class PageMultiblock extends LexiconPage {
|
||||
|
||||
public PageMultiblock(String unlocalizedName, MultiblockSet set) {
|
||||
super(unlocalizedName);
|
||||
mb = set.getForIndex(0);
|
||||
mb = set.getForFacing(EnumFacing.SOUTH);
|
||||
this.set = set;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user