mirror of
https://github.com/GTNewHorizons/Botania.git
synced 2026-10-26 14:24:22 +00:00
Compare commits
35
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9aa3a623bd | ||
|
|
1e2aecb3d4 | ||
|
|
0de40159e4 | ||
|
|
e676b13e36 | ||
|
|
a9112a40fb | ||
|
|
9da2885b18 | ||
|
|
1cf98f845c | ||
|
|
3eb0af80bc | ||
|
|
294abf403b | ||
|
|
04345bb0e9 | ||
|
|
4bbb0e96c3 | ||
|
|
5325153ec4 | ||
|
|
7fd1bcb8b2 | ||
|
|
c8fe3c8c1f | ||
|
|
83512d44c4 | ||
|
|
7ad708e5d8 | ||
|
|
070e6a7407 | ||
|
|
46c88f41e3 | ||
|
|
a6445daa24 | ||
|
|
3aaf74ac35 | ||
|
|
ba991659a4 | ||
|
|
82771d41b2 | ||
|
|
a3d8aa9391 | ||
|
|
dcfa71c8f2 | ||
|
|
055aa629d0 | ||
|
|
29fe5f02e0 | ||
|
|
3bcfb4505e | ||
|
|
2b59c48ee2 | ||
|
|
3620cf91bb | ||
|
|
da5cbb6d19 | ||
|
|
ff38e8e976 | ||
|
|
8c6fb516e7 | ||
|
|
fc21641317 | ||
|
|
f601f77d95 | ||
|
|
79be44ed22 |
No files matched your search
+12
-6
@@ -1,16 +1,22 @@
|
||||
// Add your dependencies here
|
||||
|
||||
dependencies {
|
||||
api('com.github.GTNewHorizons:Baubles-Expanded:2.1.8-GTNH:dev')
|
||||
api('com.github.GTNewHorizons:GTNHLib:0.6.30:dev')
|
||||
api('com.github.GTNewHorizons:Baubles-Expanded:2.1.9-GTNH:dev')
|
||||
api('com.github.GTNewHorizons:GTNHLib:0.6.36:dev')
|
||||
|
||||
compileOnly('com.github.GTNewHorizons:BuildCraft:7.1.43:api') {transitive=false}
|
||||
compileOnly('com.github.GTNewHorizons:ForgeMultipart:1.6.4:dev') {transitive=false}
|
||||
devOnlyNonPublishable('com.github.GTNewHorizons:NotEnoughItems:2.7.51-GTNH:dev')
|
||||
compileOnly('com.github.GTNewHorizons:BuildCraft:7.1.44:api') {transitive=false}
|
||||
compileOnly('com.github.GTNewHorizons:ModularUI2:2.2.15-1.7.10:dev')
|
||||
// devOnlyNonPublishable('com.github.GTNewHorizons:ModularUI2:2.2.15-1.7.10:dev')
|
||||
compileOnly('com.github.GTNewHorizons:BuildCraft:7.1.44:api') {transitive=false}
|
||||
compileOnly('com.github.GTNewHorizons:ForgeMultipart:1.6.7:dev') {transitive=false}
|
||||
|
||||
devOnlyNonPublishable('com.github.GTNewHorizons:NotEnoughItems:2.7.62-GTNH:dev')
|
||||
|
||||
compileOnly('com.github.GTNewHorizons:Railcraft:9.16.30:api') {transitive=false}
|
||||
compileOnly('com.github.GTNewHorizons:StorageDrawers:2.1.2-GTNH:api') {transitive=false}
|
||||
compileOnly('com.github.GTNewHorizons:StorageDrawers:2.1.4-GTNH:api') {transitive=false}
|
||||
compileOnly('curse.maven:cofh-lib-220333:2388748')
|
||||
compileOnly('curse.maven:minefactory-reloaded-66672:2366150')
|
||||
compileOnly('thaumcraft:Thaumcraft:1.7.10-4.2.3.5:dev')
|
||||
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
*/
|
||||
package vazkii.botania.api.mana;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.MovingObjectPosition;
|
||||
import vazkii.botania.api.internal.IManaBurst;
|
||||
@@ -33,6 +34,11 @@ public interface ILensEffect {
|
||||
*/
|
||||
public boolean collideBurst(IManaBurst burst, MovingObjectPosition pos, boolean isManaBlock, boolean dead, ItemStack stack);
|
||||
|
||||
/**
|
||||
* Player sensitive version of #collideBurst.
|
||||
*/
|
||||
boolean collideBurst(IManaBurst burst, MovingObjectPosition pos, boolean isManaBlock, boolean dead, ItemStack stack, EntityPlayer player);
|
||||
|
||||
/**
|
||||
* Called when a mana burst fired from a mana spreader with this focus is updated.
|
||||
* This is called before the update is handled.
|
||||
|
||||
@@ -1,28 +1,37 @@
|
||||
package vazkii.botania.client.core.handler;
|
||||
|
||||
import net.minecraft.client.settings.KeyBinding;
|
||||
import vazkii.botania.common.network.PacketHandler;
|
||||
import vazkii.botania.common.network.PacketLokiClear;
|
||||
import vazkii.botania.common.network.PacketLokiMirror;
|
||||
import vazkii.botania.common.network.PacketLokiToggle;
|
||||
import cpw.mods.fml.client.registry.ClientRegistry;
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
import cpw.mods.fml.common.gameevent.InputEvent;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.settings.KeyBinding;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import vazkii.botania.client.gui.loki.GuiLokiSchematics;
|
||||
import vazkii.botania.common.item.relic.ItemLokiRing;
|
||||
import vazkii.botania.common.network.PacketHandler;
|
||||
import vazkii.botania.common.network.PacketLokiClear;
|
||||
import vazkii.botania.common.network.PacketLokiMirror;
|
||||
import vazkii.botania.common.network.PacketLokiSaveSchematic;
|
||||
import vazkii.botania.common.network.PacketLokiToggle;
|
||||
|
||||
|
||||
public class KeyHandler {
|
||||
private static final KeyBinding keyToggleRingOfLoki= new KeyBinding("botaniamisc.toggleLoki", 0, "botaniamisc.keyCategory");
|
||||
private static final KeyBinding keyRingOfLokiClear= new KeyBinding("botaniamisc.ringOfLokiClear", 0, "botaniamisc.keyCategory");
|
||||
private static final KeyBinding keyRingOfLokiMirror= new KeyBinding("botaniamisc.ringOfLokiMirror", 0, "botaniamisc.keyCategory");
|
||||
private static final KeyBinding keyRingOfLokiSaveSchematic= new KeyBinding("botaniamisc.ringOfLokiSaveSchematic", 0, "botaniamisc.keyCategory");
|
||||
private static final KeyBinding keyRingOfLokiOpenUI= new KeyBinding("botaniamisc.ringOfLokiOpenUI", 0, "botaniamisc.keyCategory");
|
||||
|
||||
public KeyHandler() {
|
||||
FMLCommonHandler.instance().bus().register(this);
|
||||
ClientRegistry.registerKeyBinding(keyToggleRingOfLoki);
|
||||
ClientRegistry.registerKeyBinding(keyRingOfLokiClear);
|
||||
ClientRegistry.registerKeyBinding(keyRingOfLokiMirror);
|
||||
ClientRegistry.registerKeyBinding(keyRingOfLokiSaveSchematic);
|
||||
ClientRegistry.registerKeyBinding(keyRingOfLokiOpenUI);
|
||||
|
||||
}
|
||||
@SideOnly(Side.CLIENT)
|
||||
@@ -41,16 +50,32 @@ public class KeyHandler {
|
||||
if(keyRingOfLokiMirror.isPressed()){
|
||||
toggleRingLokiMirroring();
|
||||
}
|
||||
if(keyRingOfLokiSaveSchematic.isPressed()){
|
||||
ringOfLokiSaveSchematic();
|
||||
}
|
||||
if(keyRingOfLokiOpenUI.isPressed()) {
|
||||
ringOfLokiOpenUI();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private static void toggleRingLoki() {
|
||||
PacketHandler.INSTANCE.sendToServer(new PacketLokiToggle());
|
||||
}
|
||||
|
||||
private static void ringOfLokiClear() {
|
||||
PacketHandler.INSTANCE.sendToServer(new PacketLokiClear());
|
||||
}
|
||||
private static void toggleRingLokiMirroring() {
|
||||
PacketHandler.INSTANCE.sendToServer(new PacketLokiMirror());
|
||||
}
|
||||
private static void ringOfLokiSaveSchematic() {
|
||||
PacketHandler.INSTANCE.sendToServer(new PacketLokiSaveSchematic());
|
||||
}
|
||||
private static void ringOfLokiOpenUI() {
|
||||
if(ItemLokiRing.isModularUIEnabled) {
|
||||
ItemStack ring = ItemLokiRing.getLokiRing(Minecraft.getMinecraft().thePlayer);
|
||||
if(ring != null)
|
||||
GuiLokiSchematics.open(ring);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,146 @@
|
||||
package vazkii.botania.client.gui.loki;
|
||||
|
||||
import com.cleanroommc.modularui.api.drawable.IKey;
|
||||
import com.cleanroommc.modularui.drawable.Rectangle;
|
||||
import com.cleanroommc.modularui.factory.ClientGUI;
|
||||
import com.cleanroommc.modularui.screen.ModularPanel;
|
||||
import com.cleanroommc.modularui.screen.ModularScreen;
|
||||
import com.cleanroommc.modularui.screen.RichTooltip;
|
||||
import com.cleanroommc.modularui.utils.Alignment;
|
||||
import com.cleanroommc.modularui.utils.Color;
|
||||
import com.cleanroommc.modularui.widget.ParentWidget;
|
||||
import com.cleanroommc.modularui.widget.ScrollWidget;
|
||||
import com.cleanroommc.modularui.widget.scroll.ScrollArea;
|
||||
import com.cleanroommc.modularui.widget.scroll.VerticalScrollData;
|
||||
import com.cleanroommc.modularui.widgets.ButtonWidget;
|
||||
import com.cleanroommc.modularui.widgets.TextWidget;
|
||||
import com.cleanroommc.modularui.widgets.layout.Flow;
|
||||
import com.cleanroommc.modularui.widgets.layout.Row;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.StatCollector;
|
||||
import vazkii.botania.client.gui.mui2.Textures;
|
||||
import vazkii.botania.common.item.relic.ItemLokiRing;
|
||||
import vazkii.botania.common.network.PacketHandler;
|
||||
import vazkii.botania.common.network.PacketLokiChangeSchematic;
|
||||
import vazkii.botania.common.network.PacketLokiDeleteSchematic;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class GuiLokiSchematics {
|
||||
|
||||
private static final int WINDOW_WIDTH = 350, WINDOW_HEIGHT = 225, SCROLL_AREA_WIDTH = 350, SCROLL_AREA_HEIGHT = 200, SAVED_SCHEMATICS_HEADER_HEIGHT = 25, X_PADDING = 5, Y_PADDING = 5;
|
||||
private ArrayList<String> schematicNames;
|
||||
|
||||
public static void open(ItemStack ring) {
|
||||
ClientGUI.open(new ModularScreen(new GuiLokiSchematics().buildUI(ring)));
|
||||
}
|
||||
|
||||
private String selectedSchematic;
|
||||
|
||||
private GuiLokiSchematics() {
|
||||
}
|
||||
|
||||
public ModularPanel buildUI(ItemStack itemStack) {
|
||||
if (! ItemLokiRing.isLokiRing(itemStack)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
selectedSchematic = ItemLokiRing.getSelectedSchematic(itemStack);
|
||||
schematicNames = new ArrayList<>(ItemLokiRing.getSchematicNames(itemStack));
|
||||
|
||||
final ScrollWidget<?> scrollWidget = new ScrollWidget<>(new VerticalScrollData());
|
||||
setScrollArea(scrollWidget.getScrollArea());
|
||||
for (int i = 0; i < schematicNames.size(); i++) {
|
||||
// Final value that can be captured by lambdas
|
||||
final int rowId = i;
|
||||
Flow row = new Row();
|
||||
row.sizeRel(1f, 0.2f)
|
||||
.pos(0, rowId * (SCROLL_AREA_HEIGHT / 5 + 1))
|
||||
.padding(5, 0, 5, 5)
|
||||
.setEnabledIf((w) -> rowId < schematicNames.size())
|
||||
.background(new Rectangle()
|
||||
.setColor(i % 2 == 0 ? Color.ORANGE.brighter(3) : Color.ORANGE.brighter(2)))
|
||||
.child(
|
||||
new TextWidget(IKey.dynamic(()-> rowId < schematicNames.size() ? schematicNames.get(rowId) : ""))
|
||||
.widthRel(0.72f))
|
||||
.child(
|
||||
new ParentWidget<>()
|
||||
.tooltip(new RichTooltip()
|
||||
.add("Activate Schematic"))
|
||||
.widthRel(0.083f)
|
||||
.heightRel(1f)
|
||||
.setEnabledIf((w) -> rowId < schematicNames.size() && !schematicNames.get(rowId).equals(selectedSchematic))
|
||||
.child(
|
||||
new ButtonWidget<>()
|
||||
.onMousePressed(ignored -> {
|
||||
String key = schematicNames.get(rowId);
|
||||
PacketHandler.INSTANCE.sendToServer(new PacketLokiChangeSchematic(key));
|
||||
selectedSchematic = key;
|
||||
return true;
|
||||
})
|
||||
.background(Textures.CHECK_ICON)
|
||||
.hoverBackground(Textures.CHECK_ICON)
|
||||
.size(20, 20)
|
||||
.center()))
|
||||
.child(
|
||||
new ParentWidget<>()
|
||||
.widthRel(0.083f)
|
||||
.heightRel(1f)
|
||||
.child(
|
||||
new ButtonWidget<>()
|
||||
.tooltip(new RichTooltip()
|
||||
.add("Rename Schematic"))
|
||||
.onMousePressed(ignored -> {
|
||||
ClientGUI.open(new RenameGui(schematicNames.get(rowId)));
|
||||
return true;
|
||||
})
|
||||
.background(Textures.RENAME_ICON)
|
||||
.hoverBackground(Textures.RENAME_ICON)
|
||||
.size(20, 20)
|
||||
.center()))
|
||||
.child(
|
||||
new ParentWidget<>()
|
||||
.widthRel(0.083f)
|
||||
.heightRel(1f)
|
||||
.child(
|
||||
new ButtonWidget<>()
|
||||
.tooltip(new RichTooltip()
|
||||
.add("Delete Schematic"))
|
||||
.onMousePressed(ignored -> {
|
||||
String key = schematicNames.get(rowId);
|
||||
PacketHandler.INSTANCE.sendToServer(new PacketLokiDeleteSchematic(key));
|
||||
schematicNames.remove(rowId);
|
||||
setScrollArea(scrollWidget.getScrollArea());
|
||||
if(key.equals(selectedSchematic))
|
||||
selectedSchematic = null;
|
||||
return true;
|
||||
})
|
||||
.background(Textures.DELETE_ICON)
|
||||
.hoverBackground(Textures.DELETE_ICON)
|
||||
.size(20, 20)
|
||||
.center()));
|
||||
scrollWidget.child(
|
||||
row);
|
||||
}
|
||||
|
||||
return ModularPanel.defaultPanel("lokiSchematics")
|
||||
.child(
|
||||
new TextWidget(IKey.dynamic(() -> selectedSchematic == null ? StatCollector.translateToLocal("botaniamisc.select_schematic") : StatCollector.translateToLocal("botaniamisc.selected_schematic") + " " + selectedSchematic))
|
||||
.align(Alignment.TopCenter)
|
||||
.marginTop(8)
|
||||
.scale(0.5f))
|
||||
.child(
|
||||
scrollWidget
|
||||
.pos(10, 20)
|
||||
.widthRel(SCROLL_AREA_WIDTH - 20)
|
||||
.margin(10, 0)
|
||||
.height(SCROLL_AREA_HEIGHT - 10))
|
||||
.background(Textures.BACKGROUND_TEXTURE)
|
||||
.size(WINDOW_WIDTH, WINDOW_HEIGHT);
|
||||
}
|
||||
|
||||
private void setScrollArea(ScrollArea scrollWidget) {
|
||||
scrollWidget.getScrollY().setScrollSize(schematicNames.size() * (SCROLL_AREA_HEIGHT / 5 + 1));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,80 @@
|
||||
package vazkii.botania.client.gui.loki;
|
||||
|
||||
import com.cleanroommc.modularui.api.value.IStringValue;
|
||||
import com.cleanroommc.modularui.screen.CustomModularScreen;
|
||||
import com.cleanroommc.modularui.screen.ModularPanel;
|
||||
import com.cleanroommc.modularui.screen.viewport.ModularGuiContext;
|
||||
import com.cleanroommc.modularui.value.sync.InteractionSyncHandler;
|
||||
import com.cleanroommc.modularui.widgets.TextWidget;
|
||||
import com.cleanroommc.modularui.widgets.textfield.TextFieldWidget;
|
||||
import vazkii.botania.client.gui.mui2.Textures;
|
||||
import vazkii.botania.common.network.PacketHandler;
|
||||
import vazkii.botania.common.network.PacketLokiRenameSchematic;
|
||||
|
||||
class RenameGui extends CustomModularScreen {
|
||||
|
||||
private final String schematicToBeRenamed;
|
||||
|
||||
public RenameGui(String schematicToBeRenamed) {
|
||||
this.schematicToBeRenamed = schematicToBeRenamed;
|
||||
}
|
||||
|
||||
private String newValue = "";
|
||||
|
||||
@Override
|
||||
public void close() {
|
||||
close(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close(boolean force) {
|
||||
super.close(force);
|
||||
this.persist();
|
||||
}
|
||||
|
||||
public void persist() {
|
||||
PacketHandler.INSTANCE.sendToServer(new PacketLokiRenameSchematic(schematicToBeRenamed, newValue));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ModularPanel buildUI(ModularGuiContext context) {
|
||||
|
||||
InteractionSyncHandler handler = new InteractionSyncHandler();
|
||||
|
||||
handler.setOnKeyPressed((key) -> {
|
||||
System.out.println(key.character);
|
||||
});
|
||||
|
||||
return ModularPanel.defaultPanel("rename")
|
||||
.child(new TextWidget("Schematic Name:")
|
||||
.pos(10, 10)
|
||||
.size(180, 20))
|
||||
.child(new TextFieldWidget()
|
||||
.value(new IStringValue<String>() {
|
||||
@Override
|
||||
public String getStringValue() {
|
||||
return newValue;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setStringValue(String val) {
|
||||
newValue = val;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getValue() {
|
||||
return newValue;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setValue(String value) {
|
||||
newValue = value;
|
||||
}
|
||||
})
|
||||
.disableHoverBackground()
|
||||
.size(150, 20)
|
||||
.pos(25, 40))
|
||||
.background(Textures.BACKGROUND_TEXTURE)
|
||||
.size(200, 100);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package vazkii.botania.client.gui.mui2;
|
||||
|
||||
import com.cleanroommc.modularui.drawable.AdaptableUITexture;
|
||||
import com.cleanroommc.modularui.drawable.UITexture;
|
||||
|
||||
public class Textures {
|
||||
public static final UITexture BACKGROUND_TEXTURE = AdaptableUITexture
|
||||
.builder()
|
||||
.location("botania:textures/gui/croppedPaper")
|
||||
.imageSize(330, 252)
|
||||
.adaptable(12)
|
||||
.build();
|
||||
public static final UITexture CHECK_ICON = UITexture
|
||||
.builder()
|
||||
.location("botania:textures/gui/check")
|
||||
.imageSize(20, 20)
|
||||
.build();
|
||||
public static final UITexture DELETE_ICON = UITexture
|
||||
.builder()
|
||||
.location("botania:textures/gui/delete")
|
||||
.imageSize(20, 20)
|
||||
.build();
|
||||
public static final UITexture RENAME_ICON = UITexture
|
||||
.builder()
|
||||
.location("botania:textures/gui/rename")
|
||||
.imageSize(20, 20)
|
||||
.build();
|
||||
}
|
||||
@@ -31,6 +31,7 @@ import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.FakePlayer;
|
||||
import vazkii.botania.api.lexicon.ILexiconable;
|
||||
import vazkii.botania.api.lexicon.LexiconEntry;
|
||||
import vazkii.botania.api.mana.ILens;
|
||||
@@ -51,6 +52,7 @@ public class BlockSpreader extends BlockModContainer<TileSpreader> implements IW
|
||||
|
||||
Random random;
|
||||
|
||||
|
||||
public BlockSpreader() {
|
||||
super(Material.wood);
|
||||
setHardness(2.0F);
|
||||
|
||||
@@ -10,9 +10,12 @@
|
||||
*/
|
||||
package vazkii.botania.common.block.tile.mana;
|
||||
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import java.util.WeakHashMap;
|
||||
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.ScaledResolution;
|
||||
import net.minecraft.client.renderer.RenderHelper;
|
||||
@@ -31,6 +34,9 @@ import net.minecraft.util.MovingObjectPosition;
|
||||
import net.minecraft.util.StatCollector;
|
||||
import net.minecraft.util.Vec3;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.WorldServer;
|
||||
import net.minecraftforge.common.util.FakePlayer;
|
||||
import net.minecraftforge.common.util.FakePlayerFactory;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
@@ -61,7 +67,7 @@ import vazkii.botania.common.entity.EntityManaBurst;
|
||||
import vazkii.botania.common.entity.EntityManaBurst.PositionProperties;
|
||||
import vazkii.botania.common.lib.LibBlockNames;
|
||||
|
||||
public class TileSpreader extends TileSimpleInventory implements IManaCollector, IWandBindable, IKeyLocked, IThrottledPacket, IManaSpreader, IRedirectable {
|
||||
public class TileSpreader extends TileSimpleInventory implements IManaCollector, IWandBindable, IKeyLocked, IThrottledPacket, IManaSpreader, IRedirectable {
|
||||
|
||||
private static final int MAX_MANA = 1000;
|
||||
private static final int ULTRA_MAX_MANA = 6400;
|
||||
@@ -117,7 +123,10 @@ public class TileSpreader extends TileSimpleInventory implements IManaCollector,
|
||||
public static boolean staticDreamwood = false;
|
||||
public static boolean staticUltra = false;
|
||||
|
||||
UUID identity;
|
||||
UUID identity = UUID.fromString("0d0f407d-1760-4f68-84af-3067c3ed0837");
|
||||
FakePlayer fakeplayer;
|
||||
GameProfile profile = new GameProfile(identity, "[Botania]");
|
||||
private static final WeakHashMap<World, WeakReference<EntityPlayer>> FakePlayers = new WeakHashMap<>();
|
||||
|
||||
int mana;
|
||||
int knownMana = -1;
|
||||
@@ -173,7 +182,6 @@ public class TileSpreader extends TileSimpleInventory implements IManaCollector,
|
||||
ManaNetworkEvent.addCollector(this);
|
||||
inNetwork = true;
|
||||
}
|
||||
|
||||
boolean redstone = false;
|
||||
|
||||
for(ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) {
|
||||
@@ -211,6 +219,7 @@ public class TileSpreader extends TileSimpleInventory implements IManaCollector,
|
||||
List<IManaBurst> bursts = worldObj.getEntitiesWithinAABB(IManaBurst.class, aabb);
|
||||
IManaBurst found = null;
|
||||
UUID identity = getIdentifier();
|
||||
|
||||
for(IManaBurst burst : bursts)
|
||||
if(burst != null && identity.equals(burst.getShooterUIID())) {
|
||||
found = burst;
|
||||
@@ -258,10 +267,7 @@ public class TileSpreader extends TileSimpleInventory implements IManaCollector,
|
||||
public void writeCustomNBT(NBTTagCompound cmp) {
|
||||
super.writeCustomNBT(cmp);
|
||||
|
||||
UUID identity = getIdentifier();
|
||||
cmp.setBoolean(TAG_HAS_IDENTITY, true);
|
||||
cmp.setLong(TAG_UUID_MOST, identity.getMostSignificantBits());
|
||||
cmp.setLong(TAG_UUID_LEAST, identity.getLeastSignificantBits());
|
||||
|
||||
|
||||
cmp.setInteger(TAG_MANA, mana);
|
||||
cmp.setFloat(TAG_ROTATION_X, rotationX);
|
||||
@@ -297,13 +303,6 @@ public class TileSpreader extends TileSimpleInventory implements IManaCollector,
|
||||
public void readCustomNBT(NBTTagCompound cmp) {
|
||||
super.readCustomNBT(cmp);
|
||||
|
||||
if(cmp.getBoolean(TAG_HAS_IDENTITY)) {
|
||||
long most = cmp.getLong(TAG_UUID_MOST);
|
||||
long least = cmp.getLong(TAG_UUID_LEAST);
|
||||
UUID identity = getIdentifierUnsafe();
|
||||
if(identity == null || most != identity.getMostSignificantBits() || least != identity.getLeastSignificantBits())
|
||||
identity = new UUID(most, least);
|
||||
} else getIdentifier();
|
||||
|
||||
mana = cmp.getInteger(TAG_MANA);
|
||||
rotationX = cmp.getFloat(TAG_ROTATION_X);
|
||||
@@ -465,7 +464,8 @@ public class TileSpreader extends TileSimpleInventory implements IManaCollector,
|
||||
|
||||
public EntityManaBurst getBurst(boolean fake) {
|
||||
EntityManaBurst burst = new EntityManaBurst(this, fake);
|
||||
|
||||
setFakeplayer();
|
||||
burst.setPlayer(fakeplayer);
|
||||
boolean dreamwood = isDreamwood();
|
||||
boolean ultra = isULTRA_SPREADER();
|
||||
int maxMana = ultra ? 640 : dreamwood ? 240 : 160;
|
||||
@@ -753,13 +753,17 @@ public class TileSpreader extends TileSimpleInventory implements IManaCollector,
|
||||
|
||||
@Override
|
||||
public UUID getIdentifier() {
|
||||
if(identity == null)
|
||||
identity = UUID.randomUUID();
|
||||
return identity;
|
||||
}
|
||||
|
||||
public UUID getIdentifierUnsafe() {
|
||||
return identity;
|
||||
public void setFakeplayer(){
|
||||
if(!worldObj.isRemote) {
|
||||
final WeakReference<EntityPlayer> playerref = FakePlayers.get(worldObj);
|
||||
if(playerref == null) {
|
||||
final FakePlayer player = FakePlayerFactory.get((WorldServer) worldObj, profile);
|
||||
FakePlayers.put(worldObj, new WeakReference<>(player));
|
||||
this.fakeplayer = player;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package vazkii.botania.common.core.helper;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.common.util.BlockSnapshot;
|
||||
import net.minecraftforge.event.world.BlockEvent;
|
||||
|
||||
|
||||
public class ItemHelper {
|
||||
public static boolean canPlaceBlock(World world, int x, int y, int z, int xAt, int yAt, int zAt, EntityPlayer player){
|
||||
Block block = world.getBlock(x,y,z);
|
||||
Block blockAt= world.getBlock(xAt,zAt,yAt);
|
||||
int meta = world.getBlockMetadata(x,y,z);
|
||||
BlockSnapshot snapshot = new BlockSnapshot(world,x,y,z,block,meta);
|
||||
BlockEvent.PlaceEvent event = new BlockEvent.PlaceEvent(snapshot,blockAt,player);
|
||||
MinecraftForge.EVENT_BUS.post(event);
|
||||
|
||||
return !event.isCanceled();
|
||||
}
|
||||
|
||||
public static boolean canBreakBlock(World world,int x, int y, int z,EntityPlayer player){
|
||||
Block block = world.getBlock(x,y,z);
|
||||
int meta = world.getBlockMetadata(x,y,z);
|
||||
BlockEvent.BreakEvent event = new BlockEvent.BreakEvent(x, y, z, world, block, meta, player);
|
||||
MinecraftForge.EVENT_BUS.post(event);
|
||||
boolean canMineBlock = world.canMineBlock(player,x,y,z);
|
||||
|
||||
return !event.isCanceled() && canMineBlock;
|
||||
}
|
||||
}
|
||||
@@ -82,8 +82,8 @@ public class EntityFlameRing extends Entity {
|
||||
for(EntityLivingBase entity : entities) {
|
||||
if(entity == null || MathHelper.pointDistancePlane(posX, posY, entity.posX, entity.posY) > radius)
|
||||
continue;
|
||||
|
||||
entity.setFire(4);
|
||||
if(entity.attackEntityFrom(DamageSource.onFire,1))
|
||||
entity.setFire(4);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,6 +16,10 @@ import java.util.List;
|
||||
import java.util.Random;
|
||||
import java.util.UUID;
|
||||
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import com.mojang.authlib.yggdrasil.YggdrasilGameProfileRepository;
|
||||
import com.mojang.authlib.yggdrasil.YggdrasilUserAuthentication;
|
||||
import cpw.mods.fml.common.launcher.Yggdrasil;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockBush;
|
||||
import net.minecraft.block.BlockLeaves;
|
||||
@@ -72,6 +76,7 @@ public class EntityManaBurst extends EntityThrowable implements IManaBurst {
|
||||
private static final String TAG_SHOOTER_UUID_MOST = "shooterUUIDMost";
|
||||
private static final String TAG_SHOOTER_UUID_LEAST = "shooterUUIDLeast";
|
||||
|
||||
|
||||
boolean fake = false;
|
||||
|
||||
final int dataWatcherEntries = 10;
|
||||
@@ -81,6 +86,7 @@ public class EntityManaBurst extends EntityThrowable implements IManaBurst {
|
||||
|
||||
boolean fullManaLastTick = true;
|
||||
|
||||
EntityPlayer player;
|
||||
UUID shooterIdentity = null;
|
||||
int _ticksExisted = 0;
|
||||
boolean scanBeam = false;
|
||||
@@ -122,7 +128,7 @@ public class EntityManaBurst extends EntityThrowable implements IManaBurst {
|
||||
|
||||
public EntityManaBurst(EntityPlayer player) {
|
||||
this(player.worldObj);
|
||||
|
||||
this.player = player;
|
||||
setBurstSourceCoords(0, -1, 0);
|
||||
setLocationAndAngles(player.posX, player.posY + player.getEyeHeight(), player.posZ, player.rotationYaw + 180, -player.rotationPitch);
|
||||
|
||||
@@ -612,7 +618,7 @@ public class EntityManaBurst extends EntityThrowable implements IManaBurst {
|
||||
|
||||
ILensEffect lens = getLensInstance();
|
||||
if(lens != null)
|
||||
dead = lens.collideBurst(this, movingobjectposition, collidedTile != null && collidedTile instanceof IManaReceiver && ((IManaReceiver) collidedTile).canRecieveManaFromBursts(), dead, getSourceLens());
|
||||
dead = lens.collideBurst(this, movingobjectposition, collidedTile != null && collidedTile instanceof IManaReceiver && ((IManaReceiver) collidedTile).canRecieveManaFromBursts(), dead, getSourceLens(), getPlayer());
|
||||
|
||||
if(collided && !hasAlreadyCollidedAt(movingobjectposition.blockX, movingobjectposition.blockY, movingobjectposition.blockZ))
|
||||
alreadyCollidedAt.add(getCollisionLocString(movingobjectposition.blockX, movingobjectposition.blockY, movingobjectposition.blockZ));
|
||||
@@ -665,7 +671,12 @@ public class EntityManaBurst extends EntityThrowable implements IManaBurst {
|
||||
TileEntity tile = worldObj.getTileEntity(coords.posX, coords.posY, coords.posZ);
|
||||
return tile;
|
||||
}
|
||||
|
||||
public EntityPlayer getPlayer(){
|
||||
return player;
|
||||
}
|
||||
public void setPlayer(EntityPlayer player){
|
||||
this.player = player;
|
||||
}
|
||||
@Override
|
||||
protected float getGravityVelocity() {
|
||||
return getGravity();
|
||||
@@ -817,6 +828,7 @@ public class EntityManaBurst extends EntityThrowable implements IManaBurst {
|
||||
@Override
|
||||
public void setShooterUUID(UUID uuid) {
|
||||
shooterIdentity = uuid;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -302,7 +302,7 @@ public class ItemCraftingHalo extends ItemMod implements ICraftAchievement {
|
||||
|
||||
@SubscribeEvent
|
||||
public void onItemCrafted(ItemCraftedEvent event) {
|
||||
if(!(event.craftMatrix instanceof InventoryCraftingHalo))
|
||||
if(event.player.worldObj.isRemote && !(event.craftMatrix instanceof InventoryCraftingHalo))
|
||||
return;
|
||||
|
||||
for(int i = 0; i < event.player.inventory.getSizeInventory(); i++) {
|
||||
|
||||
@@ -197,6 +197,11 @@ public class ItemLaputaShard extends ItemMod implements ILensEffect, ITinyPlanet
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean collideBurst(IManaBurst burst, MovingObjectPosition pos, boolean isManaBlock, boolean dead, ItemStack stack, EntityPlayer player) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateBurst(IManaBurst burst, ItemStack stack) {
|
||||
double speed = 0.35;
|
||||
|
||||
@@ -12,6 +12,7 @@ package vazkii.botania.common.item;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
|
||||
@@ -17,6 +17,7 @@ import net.minecraft.enchantment.EnchantmentHelper;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.Item.ToolMaterial;
|
||||
import net.minecraft.item.ItemStack;
|
||||
@@ -25,9 +26,12 @@ import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.util.MovingObjectPosition;
|
||||
import net.minecraft.util.Vec3;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.ForgeHooks;
|
||||
import net.minecraftforge.event.world.BlockEvent;
|
||||
import vazkii.botania.api.BotaniaAPI;
|
||||
import vazkii.botania.api.mana.ManaItemHandler;
|
||||
import vazkii.botania.common.core.handler.ConfigHandler;
|
||||
import vazkii.botania.common.core.helper.ItemHelper;
|
||||
import vazkii.botania.common.item.ModItems;
|
||||
import vazkii.botania.common.item.equipment.tool.elementium.ItemElementiumPick;
|
||||
import vazkii.botania.common.item.equipment.tool.terrasteel.ItemTerraPick;
|
||||
@@ -48,13 +52,14 @@ public final class ToolCommons {
|
||||
|
||||
public static void removeBlocksInIteration(EntityPlayer player, ItemStack stack, World world, int x, int y, int z, int xs, int ys, int zs, int xe, int ye, int ze, Block block, Material[] materialsListing, boolean silk, int fortune, boolean dispose) {
|
||||
float blockHardness = block == null ? 1F : block.getBlockHardness(world, x, y, z);
|
||||
|
||||
for(int x1 = xs; x1 < xe; x1++)
|
||||
for(int y1 = ys; y1 < ye; y1++)
|
||||
for(int z1 = zs; z1 < ze; z1++)
|
||||
removeBlockWithDrops(player, stack, world, x1 + x, y1 + y, z1 + z, x, y, z, block, materialsListing, silk, fortune, blockHardness, dispose);
|
||||
for (int x1 = xs; x1 < xe; x1++)
|
||||
for (int y1 = ys; y1 < ye; y1++)
|
||||
for (int z1 = zs; z1 < ze; z1++)
|
||||
removeBlockWithDrops(player, stack, world, x1 + x, y1 + y, z1 + z, x, y, z, block, materialsListing, silk, fortune, blockHardness, dispose);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static boolean isRightMaterial(Material material, Material[] materialsListing) {
|
||||
for(Material mat : materialsListing)
|
||||
if(material == mat)
|
||||
@@ -76,9 +81,8 @@ public final class ToolCommons {
|
||||
|
||||
if(block != null && blk != block)
|
||||
return;
|
||||
|
||||
Material mat = world.getBlock(x, y, z).getMaterial();
|
||||
if(!world.isRemote && blk != null && !blk.isAir(world, x, y, z) && blk.getPlayerRelativeBlockHardness(player, world, x, y, z) > 0) {
|
||||
if(!world.isRemote && ItemHelper.canBreakBlock(world,x,y,z,player) && blk != null && !blk.isAir(world, x, y, z) && blk.getPlayerRelativeBlockHardness(player, world, x, y, z) > 0) {
|
||||
if(!blk.canHarvestBlock(player, meta) || !isRightMaterial(mat, materialsListing))
|
||||
return;
|
||||
|
||||
|
||||
@@ -100,6 +100,11 @@ public class ItemTerraSword extends ItemManasteelSword implements ILensEffect, I
|
||||
return dead;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean collideBurst(IManaBurst burst, MovingObjectPosition pos, boolean isManaBlock, boolean dead, ItemStack stack, EntityPlayer player) {
|
||||
return dead;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateBurst(IManaBurst burst, ItemStack stack) {
|
||||
EntityThrowable entity = (EntityThrowable) burst;
|
||||
|
||||
@@ -237,6 +237,19 @@ public class ItemLens extends ItemMod implements ILensControl, ICompositableLens
|
||||
return dead;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean collideBurst(IManaBurst burst, MovingObjectPosition pos, boolean isManaBlock, boolean dead, ItemStack stack, EntityPlayer player) {
|
||||
EntityThrowable entity = (EntityThrowable) burst;
|
||||
|
||||
dead = getLens(stack.getItemDamage()).collideBurst(burst, entity, pos, isManaBlock, dead, stack, player);
|
||||
|
||||
ItemStack compositeLens = getCompositeLens(stack);
|
||||
if(compositeLens != null && compositeLens.getItem() instanceof ILens)
|
||||
dead = ((ILens) compositeLens.getItem()).collideBurst(burst, pos, isManaBlock, dead, compositeLens, player);
|
||||
|
||||
return dead;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateBurst(IManaBurst burst, ItemStack stack) {
|
||||
EntityThrowable entity = (EntityThrowable) burst;
|
||||
|
||||
@@ -10,9 +10,17 @@
|
||||
*/
|
||||
package vazkii.botania.common.item.lens;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.projectile.EntityThrowable;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.MovingObjectPosition;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.common.util.BlockSnapshot;
|
||||
import net.minecraftforge.event.entity.player.EntityInteractEvent;
|
||||
import net.minecraftforge.event.world.BlockEvent;
|
||||
import vazkii.botania.api.internal.IManaBurst;
|
||||
import vazkii.botania.api.mana.BurstProperties;
|
||||
import vazkii.botania.api.mana.IManaSpreader;
|
||||
@@ -23,9 +31,16 @@ public class Lens {
|
||||
// NO-OP
|
||||
}
|
||||
|
||||
protected boolean canInteract(EntityPlayer player, Entity entity){
|
||||
EntityInteractEvent event = new EntityInteractEvent(player,entity);
|
||||
return !event.isCanceled();
|
||||
}
|
||||
public boolean collideBurst(IManaBurst burst, EntityThrowable entity, MovingObjectPosition pos, boolean isManaBlock, boolean dead, ItemStack stack) {
|
||||
return dead;
|
||||
}
|
||||
public boolean collideBurst(IManaBurst burst, EntityThrowable entity, MovingObjectPosition pos, boolean isManaBlock, boolean dead, ItemStack stack, EntityPlayer player) {
|
||||
return dead;
|
||||
}
|
||||
|
||||
public void updateBurst(IManaBurst burst, EntityThrowable entity, ItemStack stack) {
|
||||
// NO-OP
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
*/
|
||||
package vazkii.botania.common.item.lens;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.projectile.EntityThrowable;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ChunkCoordinates;
|
||||
@@ -21,7 +22,7 @@ import vazkii.botania.common.core.helper.Vector3;
|
||||
public class LensBounce extends Lens {
|
||||
|
||||
@Override
|
||||
public boolean collideBurst(IManaBurst burst, EntityThrowable entity, MovingObjectPosition pos, boolean isManaBlock, boolean dead, ItemStack stack) {
|
||||
public boolean collideBurst(IManaBurst burst, EntityThrowable entity, MovingObjectPosition pos, boolean isManaBlock, boolean dead, ItemStack stack, EntityPlayer player) {
|
||||
if(!isManaBlock && pos.entityHit == null) {
|
||||
ChunkCoordinates coords = burst.getBurstSourceChunkCoordinates();
|
||||
if(coords.posX != pos.blockX || coords.posY != pos.blockY || coords.posZ != pos.blockZ) {
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
*/
|
||||
package vazkii.botania.common.item.lens;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.projectile.EntityThrowable;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ChunkCoordinates;
|
||||
@@ -20,7 +21,7 @@ import vazkii.botania.api.internal.IManaBurst;
|
||||
public class LensExplosive extends Lens {
|
||||
|
||||
@Override
|
||||
public boolean collideBurst(IManaBurst burst, EntityThrowable entity, MovingObjectPosition pos, boolean isManaBlock, boolean dead, ItemStack stack) {
|
||||
public boolean collideBurst(IManaBurst burst, EntityThrowable entity, MovingObjectPosition pos, boolean isManaBlock, boolean dead, ItemStack stack, EntityPlayer player) {
|
||||
if(!burst.isFake()) {
|
||||
ChunkCoordinates coords = burst.getBurstSourceChunkCoordinates();
|
||||
if(!entity.worldObj.isRemote && pos.entityHit == null && !isManaBlock && (pos.blockX != coords.posX || pos.blockY != coords.posY || pos.blockZ != coords.posZ))
|
||||
|
||||
@@ -11,20 +11,31 @@
|
||||
package vazkii.botania.common.item.lens;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.projectile.EntityThrowable;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ChunkCoordinates;
|
||||
import net.minecraft.util.MovingObjectPosition;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.common.util.BlockSnapshot;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import net.minecraftforge.event.world.BlockEvent;
|
||||
import vazkii.botania.api.internal.IManaBurst;
|
||||
import vazkii.botania.common.block.ModBlocks;
|
||||
import vazkii.botania.common.block.tile.TileIncensePlate;
|
||||
import vazkii.botania.common.core.helper.ItemHelper;
|
||||
|
||||
import static vazkii.botania.common.core.helper.ItemHelper.canPlaceBlock;
|
||||
|
||||
public class LensFire extends Lens {
|
||||
|
||||
@Override
|
||||
public boolean collideBurst(IManaBurst burst, EntityThrowable entity, MovingObjectPosition pos, boolean isManaBlock, boolean dead, ItemStack stack) {
|
||||
public boolean collideBurst(IManaBurst burst, EntityThrowable entity, MovingObjectPosition pos, boolean isManaBlock, boolean dead, ItemStack stack, EntityPlayer player) {
|
||||
World world = entity.worldObj;
|
||||
if(world.isRemote)
|
||||
return false;
|
||||
ChunkCoordinates coords = burst.getBurstSourceChunkCoordinates();
|
||||
if((coords.posX != pos.blockX || coords.posY != pos.blockY || coords.posZ != pos.blockZ) && !burst.isFake() && !isManaBlock) {
|
||||
ForgeDirection dir = ForgeDirection.getOrientation(pos.sideHit);
|
||||
@@ -32,20 +43,20 @@ public class LensFire extends Lens {
|
||||
int x = pos.blockX + dir.offsetX;
|
||||
int y = pos.blockY + dir.offsetY;
|
||||
int z = pos.blockZ + dir.offsetZ;
|
||||
if (canPlaceBlock(world, pos.blockX, pos.blockY, pos.blockZ, x, y, z, player)) {
|
||||
Block blockAt = world.getBlock(pos.blockX, pos.blockY, pos.blockZ);
|
||||
Block blockAt_ = world.getBlock(x, y, z);
|
||||
|
||||
Block blockAt = entity.worldObj.getBlock(pos.blockX, pos.blockY, pos.blockZ);
|
||||
Block blockAt_ = entity.worldObj.getBlock(x, y, z);
|
||||
|
||||
if(blockAt == Blocks.portal)
|
||||
entity.worldObj.setBlock(pos.blockX, pos.blockY, pos.blockZ, Blocks.air);
|
||||
else if(blockAt == ModBlocks.incensePlate) {
|
||||
TileIncensePlate plate = (TileIncensePlate) entity.worldObj.getTileEntity(pos.blockX, pos.blockY, pos.blockZ);
|
||||
plate.ignite();
|
||||
} else if(blockAt_.isAir(entity.worldObj, x, y, z))
|
||||
entity.worldObj.setBlock(x, y, z, Blocks.fire);
|
||||
if (blockAt == Blocks.portal)
|
||||
world.setBlock(pos.blockX, pos.blockY, pos.blockZ, Blocks.air);
|
||||
else if (blockAt == ModBlocks.incensePlate) {
|
||||
TileIncensePlate plate = (TileIncensePlate) world.getTileEntity(pos.blockX, pos.blockY, pos.blockZ);
|
||||
plate.ignite();
|
||||
} else if (blockAt_.isAir(world, x, y, z))
|
||||
world.setBlock(x, y, z, Blocks.fire);
|
||||
}
|
||||
}
|
||||
|
||||
return dead;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -11,6 +11,7 @@
|
||||
package vazkii.botania.common.item.lens;
|
||||
|
||||
import net.minecraft.entity.item.EntityFireworkRocket;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.projectile.EntityThrowable;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.ItemStack;
|
||||
@@ -24,7 +25,7 @@ import vazkii.botania.common.core.helper.ItemNBTHelper;
|
||||
public class LensFirework extends Lens {
|
||||
|
||||
@Override
|
||||
public boolean collideBurst(IManaBurst burst, EntityThrowable entity, MovingObjectPosition pos, boolean isManaBlock, boolean dead, ItemStack stack) {
|
||||
public boolean collideBurst(IManaBurst burst, EntityThrowable entity, MovingObjectPosition pos, boolean isManaBlock, boolean dead, ItemStack stack, EntityPlayer player) {
|
||||
if(!burst.isFake()) {
|
||||
ChunkCoordinates coords = burst.getBurstSourceChunkCoordinates();
|
||||
if(!entity.worldObj.isRemote && pos.entityHit == null && !isManaBlock && (pos.blockX != coords.posX || pos.blockY != coords.posY || pos.blockZ != coords.posZ)) {
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
package vazkii.botania.common.item.lens;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.projectile.EntityThrowable;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.ItemStack;
|
||||
@@ -22,10 +23,14 @@ import vazkii.botania.api.internal.IManaBurst;
|
||||
import vazkii.botania.common.block.ModBlocks;
|
||||
import vazkii.botania.common.block.tile.TileManaFlame;
|
||||
|
||||
import static vazkii.botania.common.core.helper.ItemHelper.canPlaceBlock;
|
||||
|
||||
public class LensLight extends Lens {
|
||||
|
||||
@Override
|
||||
public boolean collideBurst(IManaBurst burst, EntityThrowable entity, MovingObjectPosition pos, boolean isManaBlock, boolean dead, ItemStack stack) {
|
||||
public boolean collideBurst(IManaBurst burst, EntityThrowable entity, MovingObjectPosition pos, boolean isManaBlock, boolean dead, ItemStack stack, EntityPlayer player) {
|
||||
if(entity.worldObj.isRemote)
|
||||
return false;
|
||||
ChunkCoordinates coords = burst.getBurstSourceChunkCoordinates();
|
||||
if((coords.posX != pos.blockX || coords.posY != pos.blockY || coords.posZ != pos.blockZ) && !burst.isFake() && !isManaBlock) {
|
||||
ForgeDirection dir = ForgeDirection.getOrientation(pos.sideHit);
|
||||
@@ -36,15 +41,16 @@ public class LensLight extends Lens {
|
||||
|
||||
Block blockAt = entity.worldObj.getBlock(pos.blockX, pos.blockY, pos.blockZ);
|
||||
Block blockAt_ = entity.worldObj.getBlock(x, y, z);
|
||||
if (canPlaceBlock(entity.worldObj,pos.blockX, pos.blockY, pos.blockZ,x,y,z,player)){
|
||||
if (blockAt == ModBlocks.manaFlame)
|
||||
entity.worldObj.setBlock(pos.blockX, pos.blockY, pos.blockZ, Blocks.air);
|
||||
else if (blockAt_.isAir(entity.worldObj, x, y, z) || blockAt_.isReplaceable(entity.worldObj, x, y, z)) {
|
||||
entity.worldObj.setBlock(x, y, z, ModBlocks.manaFlame);
|
||||
TileEntity tile = entity.worldObj.getTileEntity(x, y, z);
|
||||
|
||||
if(blockAt == ModBlocks.manaFlame)
|
||||
entity.worldObj.setBlock(pos.blockX, pos.blockY, pos.blockZ, Blocks.air);
|
||||
else if(blockAt_.isAir(entity.worldObj, x, y, z) || blockAt_.isReplaceable(entity.worldObj, x, y, z)) {
|
||||
entity.worldObj.setBlock(x, y, z, ModBlocks.manaFlame);
|
||||
TileEntity tile = entity.worldObj.getTileEntity(x, y, z);
|
||||
|
||||
if(tile instanceof TileManaFlame)
|
||||
((TileManaFlame) tile).setColor(burst.getColor());
|
||||
if (tile instanceof TileManaFlame)
|
||||
((TileManaFlame) tile).setColor(burst.getColor());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -15,6 +15,8 @@ import java.util.List;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.entity.projectile.EntityThrowable;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.ItemStack;
|
||||
@@ -22,12 +24,17 @@ import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.ChunkCoordinates;
|
||||
import net.minecraft.util.MovingObjectPosition;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.ForgeHooks;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.event.world.BlockEvent;
|
||||
import vazkii.botania.api.internal.IManaBurst;
|
||||
import vazkii.botania.api.mana.IManaBlock;
|
||||
import vazkii.botania.common.block.ModBlocks;
|
||||
import vazkii.botania.common.core.handler.ConfigHandler;
|
||||
import vazkii.botania.common.item.ModItems;
|
||||
|
||||
import static vazkii.botania.common.core.helper.ItemHelper.canBreakBlock;
|
||||
|
||||
public class LensMine extends Lens {
|
||||
|
||||
@Override
|
||||
@@ -83,4 +90,58 @@ public class LensMine extends Lens {
|
||||
return dead;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public boolean collideBurst(IManaBurst burst, EntityThrowable entity, MovingObjectPosition pos, boolean isManaBlock, boolean dead, ItemStack stack, EntityPlayer player) {
|
||||
World world = entity.worldObj;
|
||||
int x = pos.blockX;
|
||||
int y = pos.blockY;
|
||||
int z = pos.blockZ;
|
||||
Block block = world.getBlock(x, y, z);
|
||||
int meta = world.getBlockMetadata(x, y, z);
|
||||
ItemStack composite = ((ItemLens) ModItems.lens).getCompositeLens(stack);
|
||||
boolean warp = composite != null && composite.getItem() == ModItems.lens && composite.getItemDamage() == ItemLens.WARP;
|
||||
|
||||
if(warp && (block == ModBlocks.pistonRelay || block == Blocks.piston || block == Blocks.piston_extension || block == Blocks.piston_head))
|
||||
return false;
|
||||
|
||||
int harvestLevel = ConfigHandler.harvestLevelBore;
|
||||
|
||||
TileEntity tile = world.getTileEntity(x, y, z);
|
||||
if(world.isRemote)
|
||||
return false;
|
||||
float hardness = block.getBlockHardness(world, x, y, z);
|
||||
int neededHarvestLevel = block.getHarvestLevel(meta);
|
||||
int mana = burst.getMana();
|
||||
|
||||
ChunkCoordinates coords = burst.getBurstSourceChunkCoordinates();
|
||||
if(canBreakBlock(world, x, y, z, player) && (coords.posX != x || coords.posY != y || coords.posZ != z) && !(tile instanceof IManaBlock) && neededHarvestLevel <= harvestLevel && hardness != -1 && hardness < 50F && (burst.isFake() || mana >= 24)) {
|
||||
List<ItemStack> items = new ArrayList<>();
|
||||
items.addAll(block.getDrops(world, x, y, z, meta, 0));
|
||||
if (!burst.hasAlreadyCollidedAt(x, y, z)) {
|
||||
if (!burst.isFake() && !entity.worldObj.isRemote) {
|
||||
world.setBlockToAir(x, y, z);
|
||||
if (ConfigHandler.blockBreakParticles)
|
||||
entity.worldObj.playAuxSFX(2001, x, y, z, Block.getIdFromBlock(block) + (meta << 12));
|
||||
|
||||
boolean offBounds = coords.posY < 0;
|
||||
boolean doWarp = warp && !offBounds;
|
||||
int dropX = doWarp ? coords.posX : x;
|
||||
int dropY = doWarp ? coords.posY : y;
|
||||
int dropZ = doWarp ? coords.posZ : z;
|
||||
|
||||
for (ItemStack stack_ : items)
|
||||
world.spawnEntityInWorld(new EntityItem(world, dropX + 0.5, dropY + 0.5, dropZ + 0.5, stack_));
|
||||
|
||||
burst.setMana(mana - 24);
|
||||
}
|
||||
}
|
||||
dead = false;
|
||||
}
|
||||
|
||||
|
||||
return dead;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -15,6 +15,7 @@ import java.util.List;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.passive.EntitySheep;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.projectile.EntityThrowable;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
@@ -25,19 +26,25 @@ import vazkii.botania.api.BotaniaAPI;
|
||||
import vazkii.botania.api.internal.IManaBurst;
|
||||
import vazkii.botania.common.Botania;
|
||||
|
||||
import static vazkii.botania.common.core.helper.ItemHelper.canBreakBlock;
|
||||
|
||||
public class LensPaint extends Lens {
|
||||
|
||||
@Override
|
||||
public boolean collideBurst(IManaBurst burst, EntityThrowable entity, MovingObjectPosition pos, boolean isManaBlock, boolean dead, ItemStack stack) {
|
||||
public boolean collideBurst(IManaBurst burst, EntityThrowable entity, MovingObjectPosition pos, boolean isManaBlock, boolean dead, ItemStack stack, EntityPlayer player) {
|
||||
int storedColor = ItemLens.getStoredColor(stack);
|
||||
if(!burst.isFake() && storedColor > -1 && storedColor < 17) {
|
||||
if(pos.entityHit != null && pos.entityHit instanceof EntitySheep) {
|
||||
int r = 20;
|
||||
int sheepColor = ((EntitySheep) pos.entityHit).getFleeceColor();
|
||||
List<EntitySheep> sheepList = entity.worldObj.getEntitiesWithinAABB(EntitySheep.class, AxisAlignedBB.getBoundingBox(pos.entityHit.posX - r, pos.entityHit.posY - r, pos.entityHit.posZ - r, pos.entityHit.posX + r, pos.entityHit.posY + r, pos.entityHit.posZ + r));
|
||||
for(EntitySheep sheep : sheepList) {
|
||||
if(sheep.getFleeceColor() == sheepColor)
|
||||
sheep.setFleeceColor(storedColor == 16 ? sheep.worldObj.rand.nextInt(16) : storedColor);
|
||||
if(!entity.worldObj.isRemote) {
|
||||
for (EntitySheep sheep : sheepList) {
|
||||
if (canInteract(player, pos.entityHit)) {
|
||||
if (sheep.getFleeceColor() == sheepColor)
|
||||
sheep.setFleeceColor(storedColor == 16 ? sheep.worldObj.rand.nextInt(16) : storedColor);
|
||||
}
|
||||
}
|
||||
}
|
||||
dead = true;
|
||||
} else {
|
||||
@@ -71,15 +78,15 @@ public class LensPaint extends Lens {
|
||||
int metaThere = entity.worldObj.getBlockMetadata(coords.posX, coords.posY, coords.posZ);
|
||||
|
||||
if(metaThere != placeColor) {
|
||||
if(!entity.worldObj.isRemote)
|
||||
if(!entity.worldObj.isRemote && canBreakBlock(entity.worldObj, coords.posX, coords.posY, coords.posZ,player)) {
|
||||
entity.worldObj.setBlockMetadataWithNotify(coords.posX, coords.posY, coords.posZ, placeColor, 2);
|
||||
float[] color = EntitySheep.fleeceColorTable[placeColor];
|
||||
float r = color[0];
|
||||
float g = color[1];
|
||||
float b = color[2];
|
||||
for(int i = 0; i < 4; i++)
|
||||
Botania.proxy.sparkleFX(entity.worldObj, coords.posX + (float) Math.random(), coords.posY + (float) Math.random(), coords.posZ + (float) Math.random(), r, g, b, 0.6F + (float) Math.random() * 0.3F, 5);
|
||||
|
||||
float[] color = EntitySheep.fleeceColorTable[placeColor];
|
||||
float r = color[0];
|
||||
float g = color[1];
|
||||
float b = color[2];
|
||||
for (int i = 0; i < 4; i++)
|
||||
Botania.proxy.sparkleFX(entity.worldObj, coords.posX + (float) Math.random(), coords.posY + (float) Math.random(), coords.posZ + (float) Math.random(), r, g, b, 0.6F + (float) Math.random() * 0.3F, 5);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
*/
|
||||
package vazkii.botania.common.item.lens;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.projectile.EntityThrowable;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.MovingObjectPosition;
|
||||
@@ -18,7 +19,7 @@ import vazkii.botania.api.internal.IManaBurst;
|
||||
public class LensPhantom extends Lens {
|
||||
|
||||
@Override
|
||||
public boolean collideBurst(IManaBurst burst, EntityThrowable entity, MovingObjectPosition pos, boolean isManaBlock, boolean dead, ItemStack stack) {
|
||||
public boolean collideBurst(IManaBurst burst, EntityThrowable entity, MovingObjectPosition pos, boolean isManaBlock, boolean dead, ItemStack stack, EntityPlayer player) {
|
||||
if(!isManaBlock) {
|
||||
dead = false;
|
||||
burst.setMinManaLoss(Math.max(0, burst.getMinManaLoss() - 4));
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
package vazkii.botania.common.item.lens;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.projectile.EntityThrowable;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.ItemStack;
|
||||
@@ -20,10 +21,12 @@ import net.minecraft.util.MovingObjectPosition;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import vazkii.botania.api.internal.IManaBurst;
|
||||
|
||||
import static vazkii.botania.common.core.helper.ItemHelper.canBreakBlock;
|
||||
|
||||
public class LensPiston extends Lens {
|
||||
|
||||
@Override
|
||||
public boolean collideBurst(IManaBurst burst, EntityThrowable entity, MovingObjectPosition pos, boolean isManaBlock, boolean dead, ItemStack stack) {
|
||||
public boolean collideBurst(IManaBurst burst, EntityThrowable entity, MovingObjectPosition pos, boolean isManaBlock, boolean dead, ItemStack stack, EntityPlayer player) {
|
||||
ChunkCoordinates coords = burst.getBurstSourceChunkCoordinates();
|
||||
if((coords.posX != pos.blockX || coords.posY != pos.blockY || coords.posZ != pos.blockZ) && !burst.isFake() && !isManaBlock && !entity.worldObj.isRemote) {
|
||||
ForgeDirection dir = ForgeDirection.getOrientation(pos.sideHit).getOpposite();
|
||||
@@ -36,7 +39,7 @@ public class LensPiston extends Lens {
|
||||
int meta = entity.worldObj.getBlockMetadata(pos.blockX, pos.blockY, pos.blockZ);
|
||||
TileEntity tile = entity.worldObj.getTileEntity(pos.blockX, pos.blockY, pos.blockZ);
|
||||
|
||||
if(block.getMobilityFlag() == 0 && block != Blocks.obsidian && block.getBlockHardness(entity.worldObj, pos.blockX, pos.blockY, pos.blockZ) >= 0 && tile == null) {
|
||||
if(canBreakBlock(entity.worldObj,pos.blockX, pos.blockY, pos.blockZ,player) && block.getMobilityFlag() == 0 && block != Blocks.obsidian && block.getBlockHardness(entity.worldObj, pos.blockX, pos.blockY, pos.blockZ) >= 0 && tile == null) {
|
||||
entity.worldObj.setBlockToAir(pos.blockX, pos.blockY, pos.blockZ);
|
||||
entity.worldObj.setBlock(x, y, z, block, meta, 1 | 2);
|
||||
entity.worldObj.playAuxSFX(2001, pos.blockX, pos.blockY, pos.blockZ, Block.getIdFromBlock(block) + (meta << 12));
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
*/
|
||||
package vazkii.botania.common.item.lens;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.projectile.EntityThrowable;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
@@ -24,7 +25,7 @@ import vazkii.botania.common.core.helper.Vector3;
|
||||
public class LensRedirect extends Lens {
|
||||
|
||||
@Override
|
||||
public boolean collideBurst(IManaBurst burst, EntityThrowable entity, MovingObjectPosition pos, boolean isManaBlock, boolean dead, ItemStack stack) {
|
||||
public boolean collideBurst(IManaBurst burst, EntityThrowable entity, MovingObjectPosition pos, boolean isManaBlock, boolean dead, ItemStack stack, EntityPlayer player) {
|
||||
ChunkCoordinates coords = burst.getBurstSourceChunkCoordinates();
|
||||
if(!entity.worldObj.isRemote && pos.entityHit == null && coords.posY != -1 && (pos.blockX != coords.posX || pos.blockY != coords.posY || pos.blockZ != coords.posZ)) {
|
||||
TileEntity tile = entity.worldObj.getTileEntity(pos.blockX, pos.blockY, pos.blockZ);
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
*/
|
||||
package vazkii.botania.common.item.lens;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.projectile.EntityThrowable;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ChunkCoordinates;
|
||||
@@ -19,7 +20,7 @@ import vazkii.botania.api.internal.IManaBurst;
|
||||
public class LensStorm extends Lens {
|
||||
|
||||
@Override
|
||||
public boolean collideBurst(IManaBurst burst, EntityThrowable entity, MovingObjectPosition pos, boolean isManaBlock, boolean dead, ItemStack stack) {
|
||||
public boolean collideBurst(IManaBurst burst, EntityThrowable entity, MovingObjectPosition pos, boolean isManaBlock, boolean dead, ItemStack stack, EntityPlayer player) {
|
||||
if(!burst.isFake()) {
|
||||
ChunkCoordinates coords = burst.getBurstSourceChunkCoordinates();
|
||||
if(!entity.worldObj.isRemote && pos.entityHit == null && !isManaBlock && (pos.blockX != coords.posX || pos.blockY != coords.posY || pos.blockZ != coords.posZ))
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
package vazkii.botania.common.item.lens;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.projectile.EntityThrowable;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.MovingObjectPosition;
|
||||
@@ -21,7 +22,7 @@ import vazkii.botania.common.block.ModBlocks;
|
||||
public class LensWarp extends Lens {
|
||||
|
||||
@Override
|
||||
public boolean collideBurst(IManaBurst burst, EntityThrowable entity, MovingObjectPosition pos, boolean isManaBlock, boolean dead, ItemStack stack) {
|
||||
public boolean collideBurst(IManaBurst burst, EntityThrowable entity, MovingObjectPosition pos, boolean isManaBlock, boolean dead, ItemStack stack, EntityPlayer player) {
|
||||
if(burst.isFake())
|
||||
return dead;
|
||||
|
||||
|
||||
@@ -12,31 +12,35 @@ package vazkii.botania.common.item.lens;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.item.EntityFallingBlock;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.projectile.EntityThrowable;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.MovingObjectPosition;
|
||||
import net.minecraft.world.World;
|
||||
import vazkii.botania.api.internal.IManaBurst;
|
||||
import vazkii.botania.common.core.handler.ConfigHandler;
|
||||
|
||||
import static vazkii.botania.common.core.helper.ItemHelper.canBreakBlock;
|
||||
|
||||
public class LensWeight extends Lens {
|
||||
|
||||
@Override
|
||||
public boolean collideBurst(IManaBurst burst, EntityThrowable entity, MovingObjectPosition pos, boolean isManaBlock, boolean dead, ItemStack stack) {
|
||||
if(!burst.isFake()) {
|
||||
public boolean collideBurst(IManaBurst burst, EntityThrowable entity, MovingObjectPosition pos, boolean isManaBlock, boolean dead, ItemStack stack, EntityPlayer player) {
|
||||
if(!burst.isFake() && !entity.worldObj.isRemote) {
|
||||
World world = entity.worldObj;
|
||||
int x = pos.blockX;
|
||||
int y = pos.blockY;
|
||||
int z = pos.blockZ;
|
||||
int harvestLevel = ConfigHandler.harvestLevelWeight;
|
||||
|
||||
Block block = entity.worldObj.getBlock(x, y, z);
|
||||
Block blockBelow = entity.worldObj.getBlock(x, y - 1, z);
|
||||
int meta = entity.worldObj.getBlockMetadata(x, y, z);
|
||||
Block block = world.getBlock(x, y, z);
|
||||
Block blockBelow = world.getBlock(x, y - 1, z);
|
||||
int meta = world.getBlockMetadata(x, y, z);
|
||||
int neededHarvestLevel = block.getHarvestLevel(meta);
|
||||
|
||||
if(blockBelow.isAir(entity.worldObj, x, y - 1, z) && block.getBlockHardness(entity.worldObj, x, y, z) != -1 && neededHarvestLevel <= harvestLevel && entity.worldObj.getTileEntity(x, y, z) == null && block.canSilkHarvest(entity.worldObj, null, x, y, z, meta)) {
|
||||
EntityFallingBlock falling = new EntityFallingBlock(entity.worldObj, x + 0.5, y + 0.5, z + 0.5, block, meta);
|
||||
if(!entity.worldObj.isRemote)
|
||||
entity.worldObj.spawnEntityInWorld(falling);
|
||||
if(canBreakBlock(world,x,y,z,player) && blockBelow.isAir(world, x, y - 1, z) && block.getBlockHardness(world, x, y, z) != -1 && neededHarvestLevel <= harvestLevel && world.getTileEntity(x, y, z) == null && block.canSilkHarvest(world, null, x, y, z, meta)) {
|
||||
EntityFallingBlock falling = new EntityFallingBlock(world, x + 0.5, y + 0.5, z + 0.5, block, meta);
|
||||
world.spawnEntityInWorld(falling);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -11,10 +11,16 @@
|
||||
package vazkii.botania.common.item.relic;
|
||||
|
||||
|
||||
import java.awt.Color;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import baubles.api.BaubleType;
|
||||
import baubles.common.container.InventoryBaubles;
|
||||
import baubles.common.lib.PlayerHandler;
|
||||
import baubles.common.network.PacketSyncBauble;
|
||||
import com.gtnewhorizon.gtnhlib.GTNHLib;
|
||||
import cpw.mods.fml.common.Loader;
|
||||
import cpw.mods.fml.common.Optional;
|
||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.Minecraft;
|
||||
@@ -27,8 +33,9 @@ import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTBase;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
import net.minecraft.nbt.NBTTagString;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.util.ChunkCoordinates;
|
||||
import net.minecraft.util.EnumChatFormatting;
|
||||
@@ -51,19 +58,21 @@ import vazkii.botania.common.core.helper.ItemNBTHelper;
|
||||
import vazkii.botania.common.core.helper.LokiCursor;
|
||||
import vazkii.botania.common.item.ModItems;
|
||||
import vazkii.botania.common.item.equipment.tool.ToolCommons;
|
||||
import vazkii.botania.common.item.equipment.tool.terrasteel.ItemTerraPick;
|
||||
import vazkii.botania.common.lib.LibItemNames;
|
||||
import baubles.api.BaubleType;
|
||||
import baubles.common.container.InventoryBaubles;
|
||||
import baubles.common.lib.PlayerHandler;
|
||||
import baubles.common.network.PacketSyncBauble;
|
||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import vazkii.botania.common.network.PacketLokiHudNotificationAck;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class ItemLokiRing extends ItemRelicBauble implements IExtendedWireframeCoordinateListProvider, IManaUsingItem, IInWorldRenderable {
|
||||
|
||||
public static final boolean isModularUIEnabled = Loader.isModLoaded("modularui2");
|
||||
|
||||
private static final String TAG_CURSOR_LIST = "cursorList";
|
||||
private static final String TAG_CURSOR_PREFIX = "cursor";
|
||||
private static final String TAG_CURSOR_COUNT = "cursorCount";
|
||||
@@ -73,10 +82,13 @@ public class ItemLokiRing extends ItemRelicBauble implements IExtendedWireframeC
|
||||
private static final String TAG_MODE = "mode";
|
||||
private static final String TAG_BREAKING_MODE = "breaking";
|
||||
private static final String TAG_MIRROR_MODE = "mirror";
|
||||
private static final String TAG_SAVED_SCHEMATICS = "savedSchematics";
|
||||
private static final String TAG_CURRENT_SCHEMATIC = "currentSchematic";
|
||||
private boolean recursion = false;
|
||||
private static boolean isBreaking = false;
|
||||
|
||||
public static enum HUD_MESSAGE {
|
||||
MODE, BREAKING, CLEAR, MIRROR, INSUFFICIENT_MANA
|
||||
public enum HUD_MESSAGE {
|
||||
MODE, BREAKING, CLEAR, MIRROR, INSUFFICIENT_MANA, SCHEMATIC_SAVED
|
||||
}
|
||||
|
||||
public ItemLokiRing() {
|
||||
@@ -94,9 +106,10 @@ public class ItemLokiRing extends ItemRelicBauble implements IExtendedWireframeC
|
||||
ItemStack stack = player.getCurrentEquippedItem();
|
||||
if(stack == null) return;
|
||||
Item item = player.getCurrentEquippedItem().getItem();
|
||||
breakOnAllCursors(player, item, stack, x, y, z, side);
|
||||
if(item instanceof ISequentialBreaker || isBreaking)
|
||||
return;
|
||||
breakOnAllCursors(player, item, stack, x, y, z, side);
|
||||
}
|
||||
|
||||
|
||||
@SubscribeEvent
|
||||
public void onPlayerInteract(PlayerInteractEvent event) {
|
||||
@@ -127,23 +140,23 @@ public class ItemLokiRing extends ItemRelicBauble implements IExtendedWireframeC
|
||||
syncLokiRing(player);
|
||||
} else {
|
||||
addCursor : {
|
||||
int relX = lookPos.blockX - originCoords.posX;
|
||||
int relY = lookPos.blockY - originCoords.posY;
|
||||
int relZ = lookPos.blockZ - originCoords.posZ;
|
||||
int relX = lookPos.blockX - originCoords.posX;
|
||||
int relY = lookPos.blockY - originCoords.posY;
|
||||
int relZ = lookPos.blockZ - originCoords.posZ;
|
||||
|
||||
for(LokiCursor cursor : cursors)
|
||||
if(cursor.getX() == relX && cursor.getY() == relY && cursor.getZ() == relZ) {
|
||||
cursors.remove(cursor);
|
||||
setCursorList(lokiRing, cursors);
|
||||
if(player instanceof EntityPlayerMP)
|
||||
syncLokiRing(player);
|
||||
break addCursor;
|
||||
}
|
||||
for(LokiCursor cursor : cursors)
|
||||
if(cursor.getX() == relX && cursor.getY() == relY && cursor.getZ() == relZ) {
|
||||
cursors.remove(cursor);
|
||||
setCursorList(lokiRing, cursors);
|
||||
if(player instanceof EntityPlayerMP)
|
||||
syncLokiRing(player);
|
||||
break addCursor;
|
||||
}
|
||||
|
||||
addCursor(lokiRing, relX, relY, relZ, getRingMirrorMode(lokiRing) );
|
||||
if(player instanceof EntityPlayerMP)
|
||||
syncLokiRing(player);
|
||||
}
|
||||
addCursor(lokiRing, relX, relY, relZ, getRingMirrorMode(lokiRing) );
|
||||
if(player instanceof EntityPlayerMP)
|
||||
syncLokiRing(player);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (heldItemStack != null && event.action == Action.RIGHT_CLICK_BLOCK && lookPos != null && isRingEnabled(lokiRing)) {
|
||||
@@ -278,6 +291,94 @@ public class ItemLokiRing extends ItemRelicBauble implements IExtendedWireframeC
|
||||
stack.stackTagCompound.setByte(TAG_MIRROR_MODE, state);
|
||||
}
|
||||
|
||||
public static String getSelectedSchematic(ItemStack itemStack) {
|
||||
return itemStack.getTagCompound().getString(TAG_CURRENT_SCHEMATIC);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public static List<String> getSchematicNames(ItemStack stack) {
|
||||
Set<String> schematicNames = stack.getTagCompound().getCompoundTag(ItemLokiRing.TAG_SAVED_SCHEMATICS).func_150296_c();
|
||||
return schematicNames.stream().sorted(Comparator.comparing(Object::toString)).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
public static void saveCurrentSelectionAsSchematic(ItemStack stack) {
|
||||
if(!stack.getTagCompound().tagMap.containsKey(TAG_SAVED_SCHEMATICS)) {
|
||||
stack.getTagCompound().setTag(TAG_SAVED_SCHEMATICS, new NBTTagCompound());
|
||||
}
|
||||
NBTTagCompound map = (NBTTagCompound) stack.getTagCompound().getTag(TAG_SAVED_SCHEMATICS);
|
||||
NBTTagCompound currentState = new NBTTagCompound();
|
||||
for(String s : new String[]{
|
||||
TAG_CURSOR_LIST,
|
||||
TAG_CURSOR_PREFIX,
|
||||
TAG_CURSOR_COUNT,
|
||||
TAG_X_ORIGIN,
|
||||
TAG_Y_ORIGIN,
|
||||
TAG_Z_ORIGIN,
|
||||
TAG_BREAKING_MODE,
|
||||
TAG_MIRROR_MODE
|
||||
}) {
|
||||
if(stack.getTagCompound().getTag(s) != null)
|
||||
currentState.setTag(s, stack.getTagCompound().getTag(s));
|
||||
}
|
||||
String newSchematicName = "New Schematic";
|
||||
int idx = 1;
|
||||
if(map.hasKey(newSchematicName)) {
|
||||
do {
|
||||
newSchematicName = "New Schematic (" + idx + ")";
|
||||
idx++;
|
||||
} while (map.hasKey(newSchematicName));
|
||||
}
|
||||
map.setTag(newSchematicName, currentState);
|
||||
stack.getTagCompound().setTag(TAG_CURRENT_SCHEMATIC, new NBTTagString(newSchematicName));
|
||||
}
|
||||
|
||||
public static void changeSchematic(ItemStack stack, String schematicName) {
|
||||
if(!stack.getTagCompound().tagMap.containsKey(TAG_SAVED_SCHEMATICS)) {
|
||||
return;
|
||||
}
|
||||
NBTTagCompound map = (NBTTagCompound) stack.getTagCompound().getTag(TAG_SAVED_SCHEMATICS);
|
||||
if(!map.tagMap.containsKey(schematicName)) {
|
||||
return;
|
||||
}
|
||||
NBTTagCompound schematic = (NBTTagCompound) map.getTag(schematicName);
|
||||
for(String s : new String[]{
|
||||
TAG_CURSOR_LIST,
|
||||
TAG_CURSOR_PREFIX,
|
||||
TAG_CURSOR_COUNT,
|
||||
TAG_X_ORIGIN,
|
||||
TAG_Y_ORIGIN,
|
||||
TAG_Z_ORIGIN,
|
||||
TAG_BREAKING_MODE,
|
||||
TAG_MIRROR_MODE
|
||||
}) {
|
||||
if(schematic.getTag(s) != null) {
|
||||
stack.getTagCompound().setTag(s, schematic.getTag(s));
|
||||
}
|
||||
}
|
||||
stack.getTagCompound().setTag(TAG_CURRENT_SCHEMATIC, new NBTTagString(schematicName));
|
||||
}
|
||||
|
||||
public static void renameSchematic(ItemStack lokiStack, String schematicToBeRenamed, String newName) {
|
||||
if (lokiStack.getTagCompound().getString(ItemLokiRing.TAG_CURRENT_SCHEMATIC).equals(schematicToBeRenamed)) {
|
||||
lokiStack.getTagCompound().setString(ItemLokiRing.TAG_CURRENT_SCHEMATIC, newName);
|
||||
}
|
||||
NBTBase nbt = lokiStack.getTagCompound().getCompoundTag(ItemLokiRing.TAG_SAVED_SCHEMATICS).getTag(schematicToBeRenamed.toString());
|
||||
lokiStack.getTagCompound().getCompoundTag(ItemLokiRing.TAG_SAVED_SCHEMATICS).removeTag(schematicToBeRenamed.toString());
|
||||
lokiStack.getTagCompound().getCompoundTag(ItemLokiRing.TAG_SAVED_SCHEMATICS).setTag(newName, nbt);
|
||||
}
|
||||
|
||||
@Optional.Method(modid = "modularui2")
|
||||
public static void deleteSchematic(ItemStack lokiStack, String schematicName) {
|
||||
NBTTagCompound map = lokiStack.getTagCompound().getCompoundTag(TAG_SAVED_SCHEMATICS);
|
||||
if(map != null) {
|
||||
if(map.hasKey(schematicName)) {
|
||||
map.removeTag(schematicName);
|
||||
}
|
||||
}
|
||||
if(schematicName.equals(lokiStack.getTagCompound().getString(TAG_CURRENT_SCHEMATIC))) {
|
||||
lokiStack.getTagCompound().removeTag(TAG_CURRENT_SCHEMATIC);
|
||||
}
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public static void renderHUDNotification(HUD_MESSAGE type){
|
||||
@@ -291,7 +392,7 @@ public class ItemLokiRing extends ItemRelicBauble implements IExtendedWireframeC
|
||||
text = getLokiBreakingModeText(getLokiRing(mc.thePlayer));
|
||||
break;
|
||||
case CLEAR:
|
||||
text = getLokiCearText(getLokiRing(mc.thePlayer));
|
||||
text = getLokiClearText();
|
||||
break;
|
||||
case MIRROR:
|
||||
text = getLokiMirrorText(getLokiRing(mc.thePlayer));
|
||||
@@ -299,6 +400,9 @@ public class ItemLokiRing extends ItemRelicBauble implements IExtendedWireframeC
|
||||
case INSUFFICIENT_MANA:
|
||||
text = EnumChatFormatting.RED + StatCollector.translateToLocal("botaniamisc.insufficient_mana");
|
||||
break;
|
||||
case SCHEMATIC_SAVED:
|
||||
text = EnumChatFormatting.GREEN + StatCollector.translateToLocal("botaniamisc.schematic_saved");
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
|
||||
@@ -329,7 +433,7 @@ public class ItemLokiRing extends ItemRelicBauble implements IExtendedWireframeC
|
||||
getAxisString(getRingMirrorMode(stack));
|
||||
}
|
||||
|
||||
public static String getLokiCearText(ItemStack stack){
|
||||
public static String getLokiClearText(){
|
||||
return EnumChatFormatting.GOLD + StatCollector.translateToLocal("botaniamisc.lokiClear");
|
||||
}
|
||||
|
||||
@@ -389,7 +493,7 @@ public class ItemLokiRing extends ItemRelicBauble implements IExtendedWireframeC
|
||||
int masterOffsetX = originCoords.posY == -1 ? 0 :x - originCoords.posX;
|
||||
int masterOffsetY = originCoords.posY == -1 ? 0 :y - originCoords.posY;
|
||||
int masterOffsetZ = originCoords.posY == -1 ? 0 :z - originCoords.posZ;
|
||||
|
||||
isBreaking = true;
|
||||
for(int i = 0; i < cursors.size(); i++) {
|
||||
LokiCursor cursor = cursors.get(i);
|
||||
int xp = x + cursor.getX();
|
||||
@@ -422,6 +526,7 @@ public class ItemLokiRing extends ItemRelicBauble implements IExtendedWireframeC
|
||||
breaker.breakOtherBlock(player, stack, xp, yp, zp, x, y, z, side);
|
||||
ToolCommons.removeBlockWithDrops(player, stack, player.worldObj, xp, yp, zp, x, y, z, block, new Material[] { block.getMaterial() }, silk, fortune, block.getBlockHardness(world, xp, yp, zp), true);
|
||||
}
|
||||
isBreaking = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -445,7 +550,7 @@ public class ItemLokiRing extends ItemRelicBauble implements IExtendedWireframeC
|
||||
addStringToTooltip(StatCollector.translateToLocal("botaniamisc.lokiMirror") + getAxisString(getRingMirrorMode(stack)), list);
|
||||
addStringToTooltip("", list);
|
||||
addStringToTooltip(StatCollector.translateToLocal("botaniamisc.lokiToggleDescription") + " " + getOnOffString(true) + EnumChatFormatting.RESET + "/"+ getOnOffString(false), list);
|
||||
addStringToTooltip(StatCollector.translateToLocal("botaniamisc.lokiBreakingDescription") + " " + getOnOffString(true) + EnumChatFormatting.RESET+"/" + getOnOffString(false), list);
|
||||
addStringToTooltip(StatCollector.translateToLocal("botaniamisc.lokiBreakingDescription") + " " + getOnOffString(true) + EnumChatFormatting.RESET+"/" + getOnOffString(false), list);
|
||||
super.addInformation(stack, player, list, adv);
|
||||
}
|
||||
|
||||
@@ -516,7 +621,7 @@ public class ItemLokiRing extends ItemRelicBauble implements IExtendedWireframeC
|
||||
baubles.common.network.PacketHandler.INSTANCE.sendTo(new PacketSyncBauble(player, getLokiRingSlot(player)), (EntityPlayerMP) player);
|
||||
}
|
||||
|
||||
private static boolean isLokiRing(ItemStack stack) {
|
||||
public static boolean isLokiRing(ItemStack stack) {
|
||||
return stack != null && (stack.getItem() == ModItems.lokiRing || stack.getItem() == ModItems.aesirRing);
|
||||
}
|
||||
|
||||
|
||||
@@ -39,6 +39,7 @@ import vazkii.botania.api.mana.IManaUsingItem;
|
||||
import vazkii.botania.api.mana.ManaItemHandler;
|
||||
import vazkii.botania.client.core.handler.ItemsRemainingRenderHandler;
|
||||
import vazkii.botania.common.block.BlockCamo;
|
||||
import vazkii.botania.common.core.helper.ItemHelper;
|
||||
import vazkii.botania.common.core.helper.ItemNBTHelper;
|
||||
import vazkii.botania.common.item.ItemMod;
|
||||
import vazkii.botania.common.lib.LibItemNames;
|
||||
@@ -46,6 +47,8 @@ import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
import static vazkii.botania.common.core.helper.ItemHelper.canPlaceBlock;
|
||||
|
||||
public class ItemExchangeRod extends ItemMod implements IManaUsingItem, IWireframeCoordinateListProvider {
|
||||
|
||||
private static final int RANGE = 3;
|
||||
@@ -90,7 +93,7 @@ public class ItemExchangeRod extends ItemMod implements IManaUsingItem, IWirefra
|
||||
} else if(canExchange(par1ItemStack) && !ItemNBTHelper.getBoolean(par1ItemStack, TAG_SWAPPING, false)) {
|
||||
Block block = getBlock(par1ItemStack);
|
||||
int meta = getBlockMeta(par1ItemStack);
|
||||
List<ChunkCoordinates> swap = getBlocksToSwap(par3World, par1ItemStack, block, meta, par4, par5, par6, null, 0);
|
||||
List<ChunkCoordinates> swap = getBlocksToSwap(par3World, par1ItemStack, par2EntityPlayer, block, meta, par4, par5, par6, null, 0);
|
||||
if(swap.size() > 0) {
|
||||
ItemNBTHelper.setBoolean(par1ItemStack, TAG_SWAPPING, true);
|
||||
ItemNBTHelper.setInt(par1ItemStack, TAG_SELECT_X, par4);
|
||||
@@ -135,27 +138,35 @@ public class ItemExchangeRod extends ItemMod implements IManaUsingItem, IWirefra
|
||||
ItemNBTHelper.setBoolean(stack, TAG_SWAPPING, false);
|
||||
return;
|
||||
}
|
||||
|
||||
//block right-clicked
|
||||
int x = ItemNBTHelper.getInt(stack, TAG_SELECT_X, 0);
|
||||
int y = ItemNBTHelper.getInt(stack, TAG_SELECT_Y, 0);
|
||||
int z = ItemNBTHelper.getInt(stack, TAG_SELECT_Z, 0);
|
||||
//block that will replace.
|
||||
Block targetBlock = getTargetBlock(stack);
|
||||
int targetMeta = getTargetBlockMeta(stack);
|
||||
List<ChunkCoordinates> swap = getBlocksToSwap(world, stack, block, meta, x, y, z, targetBlock, targetMeta);
|
||||
if(swap.size() == 0) {
|
||||
//list of blocks to replace
|
||||
List<ChunkCoordinates> swap = getBlocksToSwap(world, stack,player ,block, meta, x, y, z, targetBlock, targetMeta);
|
||||
if(swap.isEmpty()) {
|
||||
ItemNBTHelper.setBoolean(stack, TAG_SWAPPING, false);
|
||||
return;
|
||||
}
|
||||
|
||||
ChunkCoordinates coords = swap.get(world.rand.nextInt(swap.size()));
|
||||
boolean exchange = exchange(world, player, coords.posX, coords.posY, coords.posZ, stack, block, meta);
|
||||
if(exchange)
|
||||
ManaItemHandler.requestManaExactForTool(stack, player, COST, true);
|
||||
else ItemNBTHelper.setBoolean(stack, TAG_SWAPPING, false);
|
||||
for(ChunkCoordinates coords: swap){
|
||||
boolean exchange = exchange(world, player, coords.posX, coords.posY, coords.posZ, stack, block, meta);
|
||||
if(exchange)
|
||||
ManaItemHandler.requestManaExactForTool(stack, player, COST, true);
|
||||
}
|
||||
ItemNBTHelper.setBoolean(stack, TAG_SWAPPING, false);
|
||||
// ChunkCoordinates coords = swap.get(world.rand.nextInt(swap.size()));
|
||||
//
|
||||
// boolean exchange = exchange(world, player, coords.posX, coords.posY, coords.posZ, stack, block, meta);
|
||||
// if(exchange)
|
||||
//
|
||||
// else
|
||||
}
|
||||
}
|
||||
|
||||
public List<ChunkCoordinates> getBlocksToSwap(World world, ItemStack stack, Block blockToSwap, int metaToSwap, int xc, int yc, int zc, Block targetBlock, int targetMeta) {
|
||||
public List<ChunkCoordinates> getBlocksToSwap(World world, ItemStack stack,EntityPlayer player, Block blockToSwap, int metaToSwap, int xc, int yc, int zc, Block targetBlock, int targetMeta) {
|
||||
// If we have no target block passed in, infer it to be
|
||||
// the block which the swapping is centered on (presumably the block
|
||||
// which the player is looking at)
|
||||
@@ -222,15 +233,17 @@ public class ItemExchangeRod extends ItemMod implements IManaUsingItem, IWirefra
|
||||
int meta = world.getBlockMetadata(x, y, z);
|
||||
if(!blockAt.isAir(world, x, y, z) && blockAt.getPlayerRelativeBlockHardness(player, world, x, y, z) > 0 && (blockAt != blockToSet || meta != metaToSet)) {
|
||||
if(!world.isRemote) {
|
||||
if(!player.capabilities.isCreativeMode) {
|
||||
List<ItemStack> drops = blockAt.getDrops(world, x, y, z, meta, 0);
|
||||
for(ItemStack drop : drops)
|
||||
world.spawnEntityInWorld(new EntityItem(world, x + 0.5, y + 0.5, z + 0.5, drop));
|
||||
removeFromInventory(player, stack, blockToSet, metaToSet, true);
|
||||
if (canPlaceBlock(world, x, y, z, x, y, z, player)) {
|
||||
if (!player.capabilities.isCreativeMode) {
|
||||
List<ItemStack> drops = blockAt.getDrops(world, x, y, z, meta, 0);
|
||||
for (ItemStack drop : drops)
|
||||
world.spawnEntityInWorld(new EntityItem(world, x + 0.5, y + 0.5, z + 0.5, drop));
|
||||
removeFromInventory(player, stack, blockToSet, metaToSet, true);
|
||||
}
|
||||
world.playAuxSFX(2001, x, y, z, Block.getIdFromBlock(blockAt) + (meta << 12));
|
||||
world.setBlock(x, y, z, blockToSet, metaToSet, 1 | 2);
|
||||
blockToSet.onBlockPlacedBy(world, x, y, z, player, placeStack);
|
||||
}
|
||||
world.playAuxSFX(2001, x, y, z, Block.getIdFromBlock(blockAt) + (meta << 12));
|
||||
world.setBlock(x, y, z, blockToSet, metaToSet, 1 | 2);
|
||||
blockToSet.onBlockPlacedBy(world, x, y, z, player, placeStack);
|
||||
}
|
||||
displayRemainderCounter(player, stack);
|
||||
return true;
|
||||
@@ -329,8 +342,8 @@ public class ItemExchangeRod extends ItemMod implements IManaUsingItem, IWirefra
|
||||
Block block = getBlock(stack);
|
||||
int meta = getBlockMeta(stack);
|
||||
int count = getInventoryItemCount(player, stack, block, meta);
|
||||
if(!player.worldObj.isRemote)
|
||||
ItemsRemainingRenderHandler.set(new ItemStack(block, 1, meta), count);
|
||||
//if(!player.worldObj.isRemote)
|
||||
//ItemsRemainingRenderHandler.set(new ItemStack(block, 1, meta), count);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -414,7 +427,7 @@ public class ItemExchangeRod extends ItemMod implements IManaUsingItem, IWirefra
|
||||
}
|
||||
|
||||
if(!player.worldObj.isAirBlock(x, y, z)) {
|
||||
List<ChunkCoordinates> coordsList = getBlocksToSwap(player.worldObj, stack, block, meta, x, y, z, targetBlock, targetMeta);
|
||||
List<ChunkCoordinates> coordsList = getBlocksToSwap(player.worldObj, stack,player, block, meta, x, y, z, targetBlock, targetMeta);
|
||||
for(ChunkCoordinates coords : coordsList)
|
||||
if(coords.posX == x && coords.posY == y && coords.posZ == z) {
|
||||
coordsList.remove(coords);
|
||||
|
||||
@@ -25,6 +25,7 @@ import vazkii.botania.api.item.IManaProficiencyArmor;
|
||||
import vazkii.botania.api.mana.IManaUsingItem;
|
||||
import vazkii.botania.api.mana.ManaItemHandler;
|
||||
import vazkii.botania.common.Botania;
|
||||
import vazkii.botania.common.core.helper.ItemHelper;
|
||||
import vazkii.botania.common.item.ItemMod;
|
||||
import vazkii.botania.common.item.equipment.tool.ToolCommons;
|
||||
import vazkii.botania.common.lib.LibItemNames;
|
||||
@@ -82,7 +83,7 @@ public class ItemSmeltRod extends ItemMod implements IManaUsingItem {
|
||||
data.progress--;
|
||||
decremented = true;
|
||||
if(data.progress <= 0) {
|
||||
if(!p.worldObj.isRemote) {
|
||||
if(!p.worldObj.isRemote && ItemHelper.canBreakBlock(p.worldObj,pos.blockX, pos.blockY, pos.blockZ,p)) {
|
||||
p.worldObj.setBlock(pos.blockX, pos.blockY, pos.blockZ, Block.getBlockFromItem(result.getItem()), result.getItemDamage(), 1 | 2);
|
||||
p.worldObj.playSoundAtEntity(p, "fire.ignite", 0.6F, 1F);
|
||||
p.worldObj.playSoundAtEntity(p, "fire.fire", 1F, 1F);
|
||||
|
||||
@@ -34,6 +34,7 @@ import vazkii.botania.api.subtile.ISpecialFlower;
|
||||
import vazkii.botania.common.Botania;
|
||||
import vazkii.botania.common.achievement.ICraftAchievement;
|
||||
import vazkii.botania.common.achievement.ModAchievements;
|
||||
import vazkii.botania.common.core.helper.ItemHelper;
|
||||
import vazkii.botania.common.item.ItemMod;
|
||||
import vazkii.botania.common.lib.LibItemNames;
|
||||
import vazkii.botania.common.lib.LibMisc;
|
||||
@@ -160,7 +161,8 @@ public class ItemTerraformRod extends ItemMod implements IManaUsingItem, IBlockP
|
||||
if(par2World.isRemote || ManaItemHandler.requestManaExactForTool(par1ItemStack, par3EntityPlayer, cost, true)) {
|
||||
if(!par2World.isRemote)
|
||||
for(CoordsWithBlock block : blocks)
|
||||
par2World.setBlock(block.posX, block.posY, block.posZ, block.block);
|
||||
if(ItemHelper.canBreakBlock(par2World,block.posX, block.posY, block.posZ, par3EntityPlayer))
|
||||
par2World.setBlock(block.posX, block.posY, block.posZ, block.block);
|
||||
|
||||
if(!blocks.isEmpty()) {
|
||||
for(int i = 0; i < 10; i++)
|
||||
|
||||
@@ -45,17 +45,17 @@ public class GuiHandler implements IGuiHandler {
|
||||
@Override
|
||||
public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
|
||||
switch(ID) {
|
||||
case LibGuiIDs.LEXICON :
|
||||
GuiLexicon lex = GuiLexicon.currentOpenLexicon;
|
||||
return lex;
|
||||
case LibGuiIDs.CRAFTING_HALO :
|
||||
return new GuiCraftingHalo(player.inventory, world);
|
||||
case LibGuiIDs.FLOWER_BAG :
|
||||
return new GuiFlowerBag(player);
|
||||
case LibGuiIDs.SHROOM_BAG:
|
||||
return new GuiShroomBag(player);
|
||||
case LibGuiIDs.BAUBLE_BOX :
|
||||
return new GuiBaubleBox(player);
|
||||
case LibGuiIDs.LEXICON :
|
||||
GuiLexicon lex = GuiLexicon.currentOpenLexicon;
|
||||
return lex;
|
||||
case LibGuiIDs.CRAFTING_HALO :
|
||||
return new GuiCraftingHalo(player.inventory, world);
|
||||
case LibGuiIDs.FLOWER_BAG :
|
||||
return new GuiFlowerBag(player);
|
||||
case LibGuiIDs.SHROOM_BAG:
|
||||
return new GuiShroomBag(player);
|
||||
case LibGuiIDs.BAUBLE_BOX :
|
||||
return new GuiBaubleBox(player);
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
package vazkii.botania.common.network;
|
||||
|
||||
import vazkii.botania.common.lib.LibMisc;
|
||||
import cpw.mods.fml.common.network.NetworkRegistry;
|
||||
import cpw.mods.fml.common.network.simpleimpl.SimpleNetworkWrapper;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import vazkii.botania.common.lib.LibMisc;
|
||||
|
||||
public class PacketHandler {
|
||||
|
||||
@@ -16,6 +16,10 @@ public class PacketHandler {
|
||||
INSTANCE.registerMessage(PacketLokiToggle.class, PacketLokiToggle.class, 1, Side.SERVER);
|
||||
INSTANCE.registerMessage(PacketLokiClear.class, PacketLokiClear.class, 2, Side.SERVER);
|
||||
INSTANCE.registerMessage(PacketLokiMirror.class, PacketLokiMirror.class, 3, Side.SERVER);
|
||||
INSTANCE.registerMessage(PacketLokiHudNotificationAck.class, PacketLokiHudNotificationAck.class, 4, Side.CLIENT);
|
||||
INSTANCE.registerMessage(PacketLokiSaveSchematic.class, PacketLokiSaveSchematic.class, 4, Side.SERVER);
|
||||
INSTANCE.registerMessage(PacketLokiChangeSchematic.class, PacketLokiChangeSchematic.class, 5, Side.SERVER);
|
||||
INSTANCE.registerMessage(PacketLokiDeleteSchematic.class, PacketLokiDeleteSchematic.class, 6, Side.SERVER);
|
||||
INSTANCE.registerMessage(PacketLokiRenameSchematic.class, PacketLokiRenameSchematic.class, 7, Side.SERVER);
|
||||
INSTANCE.registerMessage(PacketLokiHudNotificationAck.class, PacketLokiHudNotificationAck.class, 8, Side.CLIENT);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
package vazkii.botania.common.network;
|
||||
|
||||
import cpw.mods.fml.common.network.simpleimpl.IMessage;
|
||||
import cpw.mods.fml.common.network.simpleimpl.IMessageHandler;
|
||||
import cpw.mods.fml.common.network.simpleimpl.MessageContext;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import vazkii.botania.common.item.relic.ItemLokiRing;
|
||||
|
||||
public class PacketLokiChangeSchematic implements IMessage, IMessageHandler<PacketLokiChangeSchematic, IMessage> {
|
||||
|
||||
private String schematicName;
|
||||
|
||||
public PacketLokiChangeSchematic() {
|
||||
}
|
||||
|
||||
public PacketLokiChangeSchematic(String schematicName) {
|
||||
this.schematicName = schematicName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fromBytes(ByteBuf buf) {
|
||||
int schematicNameLength = buf.readInt();
|
||||
this.schematicName = new String(buf.readBytes(schematicNameLength).array());
|
||||
if(schematicName.equals("null")) {
|
||||
schematicName = null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void toBytes(ByteBuf buf) {
|
||||
schematicName = schematicName == null ? "null" : schematicName;
|
||||
buf.writeInt(schematicName.length());
|
||||
buf.writeBytes(schematicName.getBytes());
|
||||
}
|
||||
|
||||
@Override
|
||||
public IMessage onMessage(PacketLokiChangeSchematic message, MessageContext ctx) {
|
||||
EntityPlayerMP player = ctx.getServerHandler().playerEntity;
|
||||
ItemStack lokiStack = ItemLokiRing.getLokiRing(player);
|
||||
if(lokiStack != null && lokiStack.getItem() instanceof ItemLokiRing) {
|
||||
ItemLokiRing.changeSchematic(lokiStack, message.schematicName);
|
||||
ItemLokiRing.syncLokiRing(player);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
package vazkii.botania.common.network;
|
||||
|
||||
import cpw.mods.fml.common.network.simpleimpl.IMessage;
|
||||
import cpw.mods.fml.common.network.simpleimpl.IMessageHandler;
|
||||
import cpw.mods.fml.common.network.simpleimpl.MessageContext;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import vazkii.botania.common.item.relic.ItemLokiRing;
|
||||
|
||||
public class PacketLokiDeleteSchematic implements IMessage, IMessageHandler<PacketLokiDeleteSchematic, IMessage> {
|
||||
|
||||
private String schematicName;
|
||||
|
||||
public PacketLokiDeleteSchematic() {
|
||||
|
||||
}
|
||||
|
||||
public PacketLokiDeleteSchematic(String schematicName) {
|
||||
this.schematicName = schematicName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fromBytes(ByteBuf buf) {
|
||||
int schematicNameLength = buf.readInt();
|
||||
this.schematicName = new String(buf.readBytes(schematicNameLength).array());
|
||||
if(schematicName.equals("null")) {
|
||||
schematicName = null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void toBytes(ByteBuf buf) {
|
||||
schematicName = schematicName == null ? "null" : schematicName;
|
||||
buf.writeInt(schematicName.length());
|
||||
buf.writeBytes(schematicName.getBytes());
|
||||
}
|
||||
|
||||
@Override
|
||||
public IMessage onMessage(PacketLokiDeleteSchematic message, MessageContext ctx) {
|
||||
EntityPlayerMP player = ctx.getServerHandler().playerEntity;
|
||||
ItemStack lokiStack = ItemLokiRing.getLokiRing(player);
|
||||
if(lokiStack != null && lokiStack.getItem() instanceof ItemLokiRing) {
|
||||
ItemLokiRing.deleteSchematic(lokiStack, message.schematicName);
|
||||
ItemLokiRing.syncLokiRing(player);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
package vazkii.botania.common.network;
|
||||
|
||||
import cpw.mods.fml.common.network.simpleimpl.IMessage;
|
||||
import cpw.mods.fml.common.network.simpleimpl.IMessageHandler;
|
||||
import cpw.mods.fml.common.network.simpleimpl.MessageContext;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import vazkii.botania.common.item.relic.ItemLokiRing;
|
||||
|
||||
public class PacketLokiRenameSchematic implements IMessage, IMessageHandler<PacketLokiRenameSchematic, IMessage> {
|
||||
|
||||
private String schematicToBeRenamed;
|
||||
private String newName;
|
||||
|
||||
public PacketLokiRenameSchematic() {
|
||||
}
|
||||
|
||||
public PacketLokiRenameSchematic(String schematicToBeRenamed, String newValue) {
|
||||
this.schematicToBeRenamed = schematicToBeRenamed;
|
||||
this.newName = newValue;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fromBytes(ByteBuf buf) {
|
||||
int schematicToBeRenamedLength = buf.readInt();
|
||||
this.schematicToBeRenamed = new String(buf.readBytes(schematicToBeRenamedLength).array());
|
||||
if(schematicToBeRenamed.equals("null")) {
|
||||
this.schematicToBeRenamed = null;
|
||||
}
|
||||
int newNameLength = buf.readInt();
|
||||
this.newName = new String(buf.readBytes(newNameLength).array());
|
||||
if(newName.equals("null")) {
|
||||
this.newName = null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void toBytes(ByteBuf buf) {
|
||||
schematicToBeRenamed = schematicToBeRenamed == null ? "null" : schematicToBeRenamed;
|
||||
buf.writeInt(schematicToBeRenamed.length());
|
||||
buf.writeBytes(schematicToBeRenamed.getBytes());
|
||||
newName = newName == null ? "null" : newName;
|
||||
buf.writeInt(newName.length());
|
||||
buf.writeBytes(newName.getBytes());
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public IMessage onMessage(PacketLokiRenameSchematic message, MessageContext ctx) {
|
||||
EntityPlayerMP player = ctx.getServerHandler().playerEntity;
|
||||
ItemStack lokiStack = ItemLokiRing.getLokiRing(player);
|
||||
if(lokiStack != null && lokiStack.getItem() instanceof ItemLokiRing) {
|
||||
ItemLokiRing.renameSchematic(lokiStack, message.schematicToBeRenamed, message.newName);
|
||||
ItemLokiRing.syncLokiRing(player);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
package vazkii.botania.common.network;
|
||||
|
||||
import cpw.mods.fml.common.network.simpleimpl.IMessage;
|
||||
import cpw.mods.fml.common.network.simpleimpl.IMessageHandler;
|
||||
import cpw.mods.fml.common.network.simpleimpl.MessageContext;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import vazkii.botania.common.item.relic.ItemLokiRing;
|
||||
|
||||
public class PacketLokiSaveSchematic implements IMessage, IMessageHandler<PacketLokiSaveSchematic, IMessage> {
|
||||
@Override
|
||||
public void fromBytes(ByteBuf buf) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void toBytes(ByteBuf buf) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public IMessage onMessage(PacketLokiSaveSchematic message, MessageContext ctx) {
|
||||
EntityPlayerMP player = ctx.getServerHandler().playerEntity;
|
||||
final ItemStack aRing = ItemLokiRing.getLokiRing(player);
|
||||
if (aRing != null) {
|
||||
ItemLokiRing.saveCurrentSelectionAsSchematic(aRing);
|
||||
ItemLokiRing.syncLokiRing(player);
|
||||
PacketHandler.INSTANCE.sendTo(new PacketLokiHudNotificationAck(ItemLokiRing.HUD_MESSAGE.SCHEMATIC_SAVED), player);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -160,6 +160,8 @@ botaniamisc.keyCategory=Botania
|
||||
#LOKI
|
||||
botaniamisc.toggleLoki=Ring of Loki Switch Key
|
||||
botaniamisc.ringOfLokiClear=Clear Ring of Loki Selection
|
||||
botaniamisc.ringOfLokiSaveSchematic=Save Ring of Loki Schematic
|
||||
botaniamisc.ringOfLokiOpenUI=Open Ring of Loki Schematic GUI
|
||||
botaniamisc.lokiOn=On
|
||||
botaniamisc.lokiOff=Off
|
||||
botaniamisc.breaking=Breaking
|
||||
@@ -172,6 +174,12 @@ botaniamisc.lokiCurrent=Current
|
||||
botaniamisc.lokiState=Ring
|
||||
botaniamisc.lokiMirror=Current mirror:
|
||||
botaniamisc.insufficient_mana=Not enough mana!
|
||||
botaniamisc.schematic_saved=Schematic successfully saved!
|
||||
|
||||
#LOKI UI
|
||||
botaniamisc.saved_schematics=Saved Schematics
|
||||
botaniamisc.select_schematic=Select a Schematic!
|
||||
botaniamisc.selected_schematic=Currently selected schematic:
|
||||
|
||||
# NEI INTEGRATION
|
||||
botania.nei.brewery=Botanical Brewery
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 286 B |
Binary file not shown.
|
After Width: | Height: | Size: 92 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 296 B |
Binary file not shown.
|
After Width: | Height: | Size: 341 B |
Reference in new issue
Block a user