Skip to content

Commit

Permalink
Fixed the Ritual Representations!
Browse files Browse the repository at this point in the history
  • Loading branch information
Tombenpotter committed Feb 1, 2015
1 parent fcd3780 commit 7434cdc
Show file tree
Hide file tree
Showing 8 changed files with 53 additions and 32 deletions.
1 change: 1 addition & 0 deletions Changelog.txt
Expand Up @@ -10,6 +10,7 @@ Abandonned trying to make my own book system. I'll just try and fix Waslie's.
Fixed a bug with the free chunk assignment. -- Removed the automatic chunk assignment. It's not useful anymore.
Added 7 different types of Ethereal Blocks. Fuun!
Updated to Blood Magic 1.3.0b-3. I didn't test the fix, but it shouldn't be crashing with it anymore.
Fixed the Ritual Representations. Now they work perfectly!

Version 1.1.9-Alpha3:
Finalized the Soul Network Manifestation system. I need now to give it a bit of fluff and couple of kicks in the butts, but it's close.
Expand Down
Expand Up @@ -2,9 +2,9 @@

import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.util.ForgeDirection;
import tombenpotter.sanguimancy.api.ICustomNBTTag;
import tombenpotter.sanguimancy.api.objects.BlockPostition;
import tombenpotter.sanguimancy.api.objects.BoolAndBlockPosList;
import tombenpotter.sanguimancy.api.ICustomNBTTag;
import tombenpotter.sanguimancy.api.objects.SNKNotBoolean;
import tombenpotter.sanguimancy.api.snManifestation.ISNComponent;
import tombenpotter.sanguimancy.api.snManifestation.ISNKnot;
Expand All @@ -28,8 +28,8 @@ public ArrayList<BlockPostition> getSNKnots() {
@Override
public BoolAndBlockPosList getComponentsInNetwork() {
BoolAndBlockPosList blockPosList = new BoolAndBlockPosList();
for (BlockPostition postition : getAdjacentISNComponents()) {
if (postition != null) {
if (getAdjacentISNComponents() != null) {
for (BlockPostition postition : getAdjacentISNComponents()) {
if (postition != null) {
if (!blockPosList.hashMap.containsKey(postition) && postition.getTile(worldObj) != null && postition.getTile(worldObj) instanceof ISNKnot) {
ISNKnot knot = (ISNKnot) postition.getTile(worldObj);
Expand Down
Expand Up @@ -9,6 +9,7 @@
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import tombenpotter.sanguimancy.Sanguimancy;
import tombenpotter.sanguimancy.api.objects.BlockPostition;
Expand Down Expand Up @@ -93,4 +94,10 @@ public void onNeighborBlockChange(World world, int x, int y, int z, Block neighb
}
}
}

@Override
public boolean shouldCheckWeakPower(IBlockAccess world, int x, int y, int z, int side) {
return true;
}

}
Expand Up @@ -9,6 +9,7 @@
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import tombenpotter.sanguimancy.Sanguimancy;
import tombenpotter.sanguimancy.api.objects.BlockPostition;
Expand Down Expand Up @@ -83,4 +84,9 @@ public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer p
}
return super.onBlockActivated(world, x, y, z, player, p_149727_6_, p_149727_7_, p_149727_8_, p_149727_9_);
}

@Override
public boolean shouldCheckWeakPower(IBlockAccess world, int x, int y, int z, int side) {
return true;
}
}
Expand Up @@ -30,7 +30,7 @@ public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double
if (tileEntity instanceof TileRitualSNPart) {
TileRitualSNPart tile = (TileRitualSNPart) tileEntity;
EntityPlayer player = Minecraft.getMinecraft().thePlayer;
if (tile.ritualPosition != null && player.getHeldItem() != null && player.getHeldItem().isItemEqual(new ItemStack(ModItems.itemSeerSigil))) {
if (player.getHeldItem() != null && player.getHeldItem().isItemEqual(new ItemStack(ModItems.itemSeerSigil))) {
renderNameTag(tile, x, y, z);
}
}
Expand Down Expand Up @@ -98,7 +98,7 @@ public void renderModel(TileRitualSNPart tile, double x, double y, double z) {
public void renderNameTag(TileRitualSNPart tile, double x, double y, double z) {
float f = 1.6F;
float f1 = 0.016666668F * f;
String s = tile.ritualPosition.toString();
String s = "x: " + String.valueOf(tile.xRitual) + " y: " + String.valueOf(tile.yRitual) + " z: " + String.valueOf(tile.zRitual);
RenderManager manager = RenderManager.instance;
FontRenderer fontrenderer = manager.getFontRenderer();
GL11.glPushMatrix();
Expand Down
Expand Up @@ -11,8 +11,8 @@
import net.minecraft.network.play.server.S35PacketUpdateTileEntity;
import net.minecraft.util.ChatComponentText;
import net.minecraft.util.StatCollector;
import tombenpotter.sanguimancy.api.objects.BlockPostition;
import tombenpotter.sanguimancy.api.EnumSNType;
import tombenpotter.sanguimancy.api.objects.BlockPostition;
import tombenpotter.sanguimancy.api.objects.SNKNotBoolean;
import tombenpotter.sanguimancy.api.snManifestation.ISNKnot;
import tombenpotter.sanguimancy.api.tile.TileBaseSNPart;
Expand Down Expand Up @@ -223,7 +223,7 @@ public void updateEntity() {
if (worldObj.getWorldTime() % 200 == 0) {
HashMap<BlockPostition, SNKNotBoolean> map = getComponentsInNetwork().hashMap;
for (BlockPostition postition : map.keySet()) {
if (map.get(postition).isSNKnot && map.get(postition).isSNKnotActive && worldObj.getBlockPowerInput(xCoord, yCoord, zCoord) > 0) {
if (map.get(postition).isSNKnot && map.get(postition).isSNKnotActive && (worldObj.getBlockPowerInput(xCoord, yCoord, zCoord) > 0 || worldObj.getStrongestIndirectPower(xCoord, yCoord, zCoord) > 0)) {
disablePart(false);
} else if (map.get(postition).isSNKnot && !map.get(postition).isSNKnotActive) {
disablePart(false);
Expand Down
52 changes: 29 additions & 23 deletions src/main/java/tombenpotter/sanguimancy/tile/TileRitualSNPart.java
Expand Up @@ -3,7 +3,6 @@
import WayofTime.alchemicalWizardry.ModItems;
import WayofTime.alchemicalWizardry.api.event.RitualRunEvent;
import WayofTime.alchemicalWizardry.api.event.RitualStopEvent;
import cpw.mods.fml.common.eventhandler.Event;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
Expand All @@ -24,7 +23,9 @@
public class TileRitualSNPart extends TileBaseSNPart implements ICustomNBTTag {

public NBTTagCompound custoomNBTTag;
public BlockPostition ritualPosition;
public int xRitual;
public int yRitual;
public int zRitual;

public TileRitualSNPart() {
MinecraftForge.EVENT_BUS.register(this);
Expand All @@ -49,14 +50,18 @@ public void onNetworkUpdate(BlockPostition originalPosition) {
public void readFromNBT(NBTTagCompound tagCompound) {
super.readFromNBT(tagCompound);
custoomNBTTag = tagCompound.getCompoundTag("customNBTTag");
ritualPosition = BlockPostition.readFromNBT(tagCompound);
this.xRitual = tagCompound.getInteger("xRitual");
this.yRitual = tagCompound.getInteger("yRitual");
this.zRitual = tagCompound.getInteger("zRitual");
}

@Override
public void writeToNBT(NBTTagCompound tagCompound) {
super.writeToNBT(tagCompound);
tagCompound.setTag("customNBTTag", custoomNBTTag);
ritualPosition.writeToNBT(tagCompound);
tagCompound.setInteger("xRitual", xRitual);
tagCompound.setInteger("yRitual", yRitual);
tagCompound.setInteger("zRitual", zRitual);
}

@Override
Expand Down Expand Up @@ -95,38 +100,39 @@ public void markDirty() {

@SubscribeEvent
public void disableLinkedRitual(RitualRunEvent event) {
if (ritualPosition != null) {
HashMap<BlockPostition, SNKNotBoolean> map = getComponentsInNetwork().hashMap;
for (BlockPostition postition : map.keySet()) {
if (map.get(postition).isSNKnot && map.get(postition).isSNKnotActive && worldObj.getBlockPowerInput(xCoord, yCoord, zCoord) > 0) {
if (event.mrs.getXCoord() == ritualPosition.x && event.mrs.getYCoord() == ritualPosition.y && event.mrs.getZCoord() == ritualPosition.z) {
ritualPosition = new BlockPostition(event.mrs.getXCoord(), event.mrs.getYCoord(), event.mrs.getZCoord());
event.setResult(Event.Result.DENY);
}
} else if (map.get(postition).isSNKnot && !map.get(postition).isSNKnotActive) {
if (event.mrs.getXCoord() == ritualPosition.x && event.mrs.getYCoord() == ritualPosition.y && event.mrs.getZCoord() == ritualPosition.z) {
ritualPosition = new BlockPostition(event.mrs.getXCoord(), event.mrs.getYCoord(), event.mrs.getZCoord());
event.setResult(Event.Result.DENY);
}
HashMap<BlockPostition, SNKNotBoolean> map = getComponentsInNetwork().hashMap;
for (BlockPostition postition : map.keySet()) {
if (map.get(postition).isSNKnot && map.get(postition).isSNKnotActive && (worldObj.getBlockPowerInput(xCoord, yCoord, zCoord) > 0 || worldObj.getStrongestIndirectPower(xCoord, yCoord, zCoord) > 0)) {
if (event.mrs.getXCoord() == xRitual && event.mrs.getYCoord() == yRitual && event.mrs.getZCoord() == zRitual) {
this.xRitual = event.mrs.getXCoord();
this.yRitual = event.mrs.getYCoord();
this.zRitual = event.mrs.getZCoord();
event.setCanceled(true);
}
}
if (map.get(postition).isSNKnot && !map.get(postition).isSNKnotActive) {
if (event.mrs.getXCoord() == xRitual && event.mrs.getYCoord() == yRitual && event.mrs.getZCoord() == zRitual) {
this.xRitual = event.mrs.getXCoord();
this.yRitual = event.mrs.getYCoord();
this.zRitual = event.mrs.getZCoord();
event.setCanceled(true);
}
}
}
}

@SubscribeEvent
public void removeMasterStone(RitualStopEvent event) {
if (ritualPosition != null) {
if (event.mrs.getXCoord() == ritualPosition.x && event.mrs.getYCoord() == ritualPosition.y && event.mrs.getZCoord() == ritualPosition.z) {
worldObj.setBlockToAir(xCoord, yCoord, zCoord);
}
if (event.mrs.getXCoord() == xRitual && event.mrs.getYCoord() == yRitual && event.mrs.getZCoord() == zRitual) {
worldObj.setBlockToAir(xCoord, yCoord, zCoord);
}
}

public boolean onBlockRightClicked(EntityPlayer player, ItemStack stack) {
if (stack != null && ritualPosition != null) {
if (stack != null) {
if (stack.isItemEqual(new ItemStack(ModItems.divinationSigil)) || stack.isItemEqual(new ItemStack(ModItems.itemSeerSigil))) {
if (!worldObj.isRemote) {
player.addChatComponentMessage(new ChatComponentText(ritualPosition.toString()));
player.addChatComponentMessage(new ChatComponentText("x: " + String.valueOf(xRitual) + " y: " + String.valueOf(yRitual) + " z: " + String.valueOf(zRitual)));
}
return true;
}
Expand Down
5 changes: 3 additions & 2 deletions src/main/java/tombenpotter/sanguimancy/util/EventHandler.java
Expand Up @@ -36,7 +36,6 @@
import net.minecraftforge.event.world.BlockEvent;
import org.lwjgl.opengl.GL11;
import tombenpotter.sanguimancy.Sanguimancy;
import tombenpotter.sanguimancy.api.objects.BlockPostition;
import tombenpotter.sanguimancy.api.soulCorruption.SoulCorruptionHelper;
import tombenpotter.sanguimancy.network.PacketHandler;
import tombenpotter.sanguimancy.network.events.EventCorruptedInfusion;
Expand Down Expand Up @@ -262,7 +261,9 @@ public void onRitualStart(RitualActivatedEvent event) {
dimWorld.setBlock(baseX, baseY, baseZ, BlocksRegistry.ritualRepresentation);
if (dimWorld.getTileEntity(baseX, baseY, baseZ) != null && dimWorld.getTileEntity(baseX, baseY, baseZ) instanceof TileRitualSNPart) {
TileRitualSNPart part = (TileRitualSNPart) dimWorld.getTileEntity(baseX, baseY, baseZ);
part.ritualPosition = new BlockPostition(event.mrs.getXCoord(), event.mrs.getYCoord(), event.mrs.getZCoord());
part.xRitual = event.mrs.getXCoord();
part.yRitual = event.mrs.getYCoord();
part.zRitual = event.mrs.getZCoord();
dimWorld.markBlockForUpdate(baseX, baseY, baseZ);
}
}
Expand Down

0 comments on commit 7434cdc

Please sign in to comment.