Compare commits

...
Author SHA1 Message Date
Dream Master 434b3d4518 update 2025-07-17 22:41:35 +07:00
Dream Master c62173b7fb Merge remote-tracking branch 'ReignOfFROZE/master' into dev
# Conflicts:
#	src/main/java/vazkii/botania/common/item/relic/ItemLokiRing.java
2025-07-17 22:40:40 +07:00
Martin Robertz 8e9865fee8 Merge branch 'master' into master 2025-07-17 22:37:42 +07:00
Martin Robertz 0fda050290 Merge branch 'master' into master 2025-07-17 22:35:47 +07:00
RubilaxXxx 711c180852 Update dependencies.gradle 2025-07-09 22:11:23 +02:00
RubilaxXxx 030c14eae8 forgot to remove serverutilities 2025-07-09 22:05:07 +02:00
RubilaxXxx 14b51c05e4 minor corrections 2025-07-09 22:02:25 +02:00
RubilaxXxx 1e2aecb3d4 recusion loop, oupsi. 2025-07-03 01:27:33 +02:00
RubilaxXxx 0de40159e4 minors 2025-07-03 00:45:22 +02:00
RubilaxXxx e676b13e36 update 2025-07-02 18:57:58 +02:00
RubilaxXxx a9112a40fb claim bypass fix --rods 2025-07-02 18:38:31 +02:00
RubilaxXxx 9da2885b18 claim bypass fix --lens 2025-07-02 15:58:35 +02:00
RubilaxXxx 1cf98f845c claim bypass fix 2025-07-01 13:49:29 +02:00
Martin Robertz 294abf403b Merge branch 'master' into master 2025-06-30 19:05:30 +02:00
ReignOfFROZE 04345bb0e9 Rebase & comments pt 1 2025-06-19 15:22:50 -04:00
Nikolay S. 4bbb0e96c3 Fix the rest of the lang file mistakes in Botania (#84) 2025-06-19 15:14:48 -04:00
Nikolay S. 5325153ec4 Add missing equals sign (#83) 2025-06-19 15:14:47 -04:00
Martin Robertz 7fd1bcb8b2 update
(cherry picked from commit 1063233a53)
2025-06-19 15:14:47 -04:00
Martin Robertz c8fe3c8c1f update
(cherry picked from commit 812c1ff336)
2025-06-19 15:14:25 -04:00
Maya 83512d44c4 update 2025-06-19 15:14:25 -04:00
brandynandMaya 7ad708e5d8 Add configurable F3 Debug (#78)
Co-authored-by: Maya <10861407+serenibyss@users.noreply.github.com>
2025-06-19 15:14:25 -04:00
Martin Robertz 070e6a7407 update 2025-06-19 15:14:25 -04:00
Caedis 46c88f41e3 Replace Baubles with Baubles Expanded (#81) 2025-06-19 15:14:25 -04:00
YannickMG a6445daa24 Fix deleting schematics leaving holes 2025-04-22 22:15:50 -04:00
YannickMG 3aaf74ac35 Cleanup pass 2025-04-22 18:38:28 -04:00
ReignOfFROZE ba991659a4 Added packet for renaming and check if the ring is null before trying to open UI 2025-03-22 13:09:00 -04:00
glowredman 82771d41b2 Don't use wildcard imports 2025-03-06 17:43:52 +01:00
ReignOfFROZE a3d8aa9391 Merge upstream/master to master 2025-03-05 10:55:17 -05:00
ReignOfFROZE dcfa71c8f2 Remove runtime dependency on MUI2 2025-03-05 10:51:39 -05:00
ReignOfFROZE 055aa629d0 Added a little bit of polish 2025-03-03 11:34:21 -05:00
ReignOfFROZE 29fe5f02e0 Organize imports 2025-03-03 11:18:26 -05:00
ReignOfFROZE 3bcfb4505e Remove useless annotation 2025-03-03 11:18:06 -05:00
ReignOfFROZE 2b59c48ee2 Adjust header text scale 2025-03-03 10:26:12 -05:00
ReignOfFROZE 3620cf91bb Added new icons and adjusted GUI scale 2025-03-03 10:20:25 -05:00
ReignOfFROZE da5cbb6d19 not sure why the pencil was big 2025-03-02 18:01:12 -05:00
ReignOfFROZE ff38e8e976 Remove unused files 2025-03-02 18:00:08 -05:00
ReignOfFROZE 8c6fb516e7 Update to MUI2 2025-03-02 17:58:32 -05:00
ReignOfFROZE fc21641317 Made ModularUI an optional dependency 2025-03-02 14:04:41 -05:00
ReignOfFROZE f601f77d95 Remove CT dep 2025-03-01 21:46:24 -05:00
ReignOfFROZE 79be44ed22 Added loki config switching 2025-03-01 21:45:35 -05:00
47 changed files with 1149 additions and 154 deletions

No files matched your search

+12 -6
View File
@@ -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.38: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.16-1.7.10:dev')
// devOnlyNonPublishable('com.github.GTNewHorizons:ModularUI2:2.2.16-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.66-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.5-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')
}
+1 -1
View File
@@ -142,7 +142,7 @@ modrinthProjectId =
# type can be one of [project, version],
# and the name is the Modrinth project or version slug/id of the other mod.
# Example: required-project:fplib;optional-project:gasstation;incompatible-project:gregtech
# Note: GTNH Mixins is automatically set as a required dependency if usesMixins = true
# Note: UniMixins is automatically set as a required dependency if usesMixins = true.
modrinthRelations =
# Publishing to CurseForge requires you to set the CURSEFORGE_TOKEN environment variable to one of your CurseForge API tokens.
+1 -1
View File
@@ -17,7 +17,7 @@ pluginManagement {
}
plugins {
id 'com.gtnewhorizons.gtnhsettingsconvention' version '1.0.38'
id 'com.gtnewhorizons.gtnhsettingsconvention' version '1.0.41'
}
@@ -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)
@@ -37,16 +46,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();
}
@@ -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");
EntityPlayer fakeplayer;
GameProfile profile = new GameProfile(identity, "[Botania]");
private static final WeakHashMap<World, WeakReference<EntityPlayer>> FakePlayers = new WeakHashMap<>();
int mana;
int knownMana = -1;
@@ -258,11 +267,6 @@ 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);
cmp.setFloat(TAG_ROTATION_Y, rotationY);
@@ -297,14 +301,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);
rotationY = cmp.getFloat(TAG_ROTATION_Y);
@@ -465,7 +461,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 +750,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;
} else fakeplayer = playerref.get();
}
}
}
@@ -0,0 +1,35 @@
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
@@ -301,6 +301,17 @@ public class ItemCraftingHalo extends ItemMod implements ICraftAchievement {
ItemNBTHelper.setCompound(stack, TAG_STORED_RECIPE_PREFIX + pos, getLastCraftingCompound(stack, false));
}
public void onItemCrafted(ItemCraftedEvent event) {
if(event.player.worldObj.isRemote && !(event.craftMatrix instanceof InventoryCraftingHalo))
return;
for(int i = 0; i < event.player.inventory.getSizeInventory(); i++) {
ItemStack stack = event.player.inventory.getStackInSlot(i);
if(stack != null && stack.getItem() instanceof ItemCraftingHalo)
saveRecipeToStack(event, stack);
}
}
private void saveRecipeToStack(ItemCraftedEvent event, ItemStack stack) {
NBTTagCompound cmp = new NBTTagCompound();
NBTTagCompound cmp1 = new NBTTagCompound();
@@ -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,15 +82,200 @@ 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() {
super(LibItemNames.LOKI_RING);
MinecraftForge.EVENT_BUS.register(new EventHandler());
MinecraftForge.EVENT_BUS.register(this);
}
@SubscribeEvent
public void onBlockBreak(BlockEvent.BreakEvent event) {
EntityPlayer player = event.getPlayer();
int x = event.x;
int y = event.y;
int z = event.z;
int side = event.blockMetadata;
ItemStack stack = player.getCurrentEquippedItem();
if(stack == null) return;
Item item = player.getCurrentEquippedItem().getItem();
breakOnAllCursors(player, item, stack, x, y, z, side);
}
@SubscribeEvent
public void onPlayerInteract(PlayerInteractEvent event) {
if(recursion) return;
EntityPlayer player = event.entityPlayer;
ItemStack lokiRing = getLokiRing(player);
if (lokiRing == null || player.worldObj.isRemote)
return;
ItemStack heldItemStack = player.getCurrentEquippedItem();
ChunkCoordinates originCoords = getOriginPos(lokiRing);
MovingObjectPosition lookPos = ToolCommons.raytraceFromEntity(player.worldObj, player, true, 10F);
List<LokiCursor> cursors = getCursorList(lokiRing);
int cursorCount = cursors.size();
//I don`t think mana for placing should be cruel , so I just made graph with funny line
int cost = (int)(50*Math.sin(0.04* cursorCount)+cursorCount+120+20*Math.cos(0.2*cursorCount));
if (heldItemStack == null && event.action == Action.RIGHT_CLICK_BLOCK && player.isSneaking() && isRingEnabled(lokiRing)) {
if(originCoords.posY == -1 && lookPos != null) {
setOriginPos(lokiRing, lookPos.blockX, lookPos.blockY, lookPos.blockZ);
if(player instanceof EntityPlayerMP)
syncLokiRing(player);
} else if(lookPos != null) {
if(originCoords.posX == lookPos.blockX && originCoords.posY == lookPos.blockY && originCoords.posZ == lookPos.blockZ) {
clearMasterCursor(lokiRing);
if(player instanceof EntityPlayerMP)
syncLokiRing(player);
} else {
addCursor : {
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;
}
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)) {
if(!ManaItemHandler.requestManaExact(lokiRing, player, cost, true)){
if(player instanceof EntityPlayerMP){
vazkii.botania.common.network.PacketHandler.INSTANCE.sendTo(new PacketLokiHudNotificationAck(HUD_MESSAGE.INSUFFICIENT_MANA),(EntityPlayerMP) player);
}
else
{
renderHUDNotification(HUD_MESSAGE.INSUFFICIENT_MANA);
}
return;
}
recursion = true;
double oldPosX = player.posX;
double oldPosY = player.posY;
double oldPosZ = player.posZ;
float oldPitch = player.rotationPitch;
float oldYaw = player.rotationYaw;
int masterOffsetX = originCoords.posY == -1 ? 0 :lookPos.blockX - originCoords.posX;
int masterOffsetY = originCoords.posY == -1 ? 0 :lookPos.blockY - originCoords.posY;
int masterOffsetZ = originCoords.posY == -1 ? 0 :lookPos.blockZ - originCoords.posZ;
double playerOffsetX = player.posX - originCoords.posX;
double playerOffsetY = player.posY - originCoords.posY;
double playerOffsetZ = player.posZ - originCoords.posZ;
for(LokiCursor cursor : cursors) {
int x = lookPos.blockX + cursor.getX();
int y = lookPos.blockY + cursor.getY();
int z = lookPos.blockZ + cursor.getZ();
if(cursor.isMirrorX()){
x -= 2*masterOffsetX;
}
if(cursor.isMirrorY()){
y -= 2*masterOffsetY;
}
if(cursor.isMirrorZ()){
z -= 2*masterOffsetZ;
}
if (player.worldObj.isAirBlock(x, y, z) ) {
continue;
}
player.posX = cursor.getX()+oldPosX;
player.posY = cursor.getY()+oldPosY;
player.posZ = cursor.getZ()+oldPosZ;
player.rotationYaw = oldYaw;
if(cursor.isMirrorX()){
player.posX -= 2*playerOffsetX;
player.rotationYaw = player.rotationYaw * (-1);
}
if(cursor.isMirrorY()){
player.posY -= 2*playerOffsetY;
player.rotationPitch = oldPitch * (-1);
}
if(cursor.isMirrorZ()){
player.posZ -= 2*playerOffsetZ;
player.rotationYaw = 180 - (Math.abs(player.rotationYaw));
if(oldYaw < 0){
player.rotationYaw *= -1;
}
}
float hitX = (float) (lookPos.hitVec.xCoord - lookPos.blockX);
float hitY = (float) (lookPos.hitVec.yCoord - lookPos.blockY);
float hitZ = (float) (lookPos.hitVec.zCoord - lookPos.blockZ);
if(cursor.isMirrorX()){
hitX = 1-hitX;
}
if(cursor.isMirrorY()){
hitY = 1-hitY;
}
if(cursor.isMirrorZ()){
hitZ = 1-hitZ;
}
int hitSide = lookPos.sideHit;
if(cursor.isMirrorX() && (hitSide == ForgeDirection.EAST.ordinal() || hitSide == ForgeDirection.WEST.ordinal()) ){
hitSide = hitSide ^ 1;
}
if(cursor.isMirrorY() && (hitSide == ForgeDirection.DOWN.ordinal() || hitSide == ForgeDirection.UP.ordinal()) ){
hitSide = hitSide ^ 1;
}
if(cursor.isMirrorZ() && (hitSide == ForgeDirection.NORTH.ordinal() || hitSide == ForgeDirection.SOUTH.ordinal()) ){
hitSide = hitSide ^ 1;
}
Item item = heldItemStack.getItem();
Block markedBlock = player.worldObj.getBlock(x, y, z);
boolean wasActivated = markedBlock.onBlockActivated(player.worldObj, x, y, z, player, hitSide, hitX,hitY,hitZ);
if (heldItemStack.stackSize == 0 ) {
event.setCanceled(true);
break;
}
if (!wasActivated) {
item.onItemUse(player.capabilities.isCreativeMode ? heldItemStack.copy() : heldItemStack, player, player.worldObj, x, y, z, hitSide, (float) lookPos.hitVec.xCoord - x, (float) lookPos.hitVec.yCoord - y, (float) lookPos.hitVec.zCoord - z);
if(heldItemStack.stackSize == 0) {
event.setCanceled(true);
break;
}
}
}
recursion = false;
player.posX = oldPosX;
player.posY = oldPosY;
player.posZ = oldPosZ;
player.rotationPitch = oldPitch;
player.rotationYaw = oldYaw;
}
}
public static void setMode(ItemStack stack, boolean state) {
@@ -96,6 +290,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){
@@ -109,7 +391,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));
@@ -117,6 +399,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;
@@ -147,7 +432,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");
}
@@ -207,7 +492,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();
@@ -240,6 +525,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
@@ -263,7 +549,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);
}
@@ -334,7 +620,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);
@@ -124,27 +127,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)
@@ -211,15 +222,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;
@@ -318,8 +331,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
@@ -403,7 +416,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