Skip to content

Commit

Permalink
Few fixes for the Forge version.
Browse files Browse the repository at this point in the history
  • Loading branch information
me4502 committed Mar 26, 2019
1 parent 8eccdc7 commit 4629c1f
Show file tree
Hide file tree
Showing 7 changed files with 55 additions and 20 deletions.
Expand Up @@ -187,8 +187,9 @@ public <B extends BlockStateHolder<B>> boolean setBlock(BlockVector3 position, B

@Override
public boolean notifyAndLightBlock(BlockVector3 position, BlockState previousType) throws WorldEditException {
// TODO Implement
return false;
BlockPos pos = new BlockPos(position.getX(), position.getY(), position.getZ());
getWorld().notifyBlockUpdate(pos, ForgeAdapter.adapt(previousType), getWorld().getBlockState(pos), 1 | 2);
return true;
}

@Override
Expand Down
Expand Up @@ -31,6 +31,9 @@
import com.sk89q.worldedit.forge.net.handler.InternalPacketHandler;
import com.sk89q.worldedit.forge.net.handler.WECUIPacketHandler;
import com.sk89q.worldedit.forge.net.packet.LeftClickAirEventMessage;
import com.sk89q.worldedit.forge.proxy.ClientProxy;
import com.sk89q.worldedit.forge.proxy.CommonProxy;
import com.sk89q.worldedit.forge.proxy.ServerProxy;
import com.sk89q.worldedit.util.Location;
import com.sk89q.worldedit.world.biome.BiomeType;
import com.sk89q.worldedit.world.block.BlockCategory;
Expand Down Expand Up @@ -89,7 +92,7 @@ public class ForgeWorldEdit {

public static ForgeWorldEdit inst;

public static CommonProxy proxy = DistExecutor.runForDist(() -> ClientProxy::new, () -> CommonProxy::new);
public static CommonProxy proxy = DistExecutor.runForDist(() -> ClientProxy::new, () -> ServerProxy::new);

private ForgePlatform platform;
private ForgeConfiguration config;
Expand Down
Expand Up @@ -41,7 +41,7 @@ public void onKey(KeyInputEvent evt) {
if (mc.player != null && mc.world != null && mainKey.isPressed()) {
mc.displayGuiScreen(new GuiReferenceCard());
// TODO Seems GuiHandlers don't work on client right now
// NetworkHooks.openGui(mc.player, new ResourceLocationInteractionObject(CommonProxy.REFERENCE_GUI));
// NetworkHooks.openGui(mc.player, new ResourceLocationInteractionObject(ServerProxy.REFERENCE_GUI));
}
}

Expand Down
Expand Up @@ -23,8 +23,11 @@
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import org.lwjgl.opengl.GL11;

@OnlyIn(Dist.CLIENT)
public class GuiReferenceCard extends GuiScreen {

private GuiButton closeButton;
Expand Down
Expand Up @@ -17,15 +17,18 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

package com.sk89q.worldedit.forge;
package com.sk89q.worldedit.forge.proxy;

import com.sk89q.worldedit.forge.KeyHandler;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.common.MinecraftForge;

public class ClientProxy extends CommonProxy {
@OnlyIn(Dist.CLIENT)
public class ClientProxy implements CommonProxy {

@Override
public void registerHandlers() {
super.registerHandlers();
MinecraftForge.EVENT_BUS.register(new KeyHandler());
}

Expand Down
@@ -0,0 +1,25 @@
/*
* WorldEdit, a Minecraft world manipulation toolkit
* Copyright (C) sk89q <http://www.sk89q.com>
* Copyright (C) WorldEdit team and contributors
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by the
* Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

package com.sk89q.worldedit.forge.proxy;

public interface CommonProxy {

void registerHandlers();
}
Expand Up @@ -17,24 +17,24 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

package com.sk89q.worldedit.forge;
package com.sk89q.worldedit.forge.proxy;

import com.sk89q.worldedit.forge.gui.GuiReferenceCard;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.fml.ExtensionPoint;
import net.minecraftforge.fml.ModLoadingContext;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;

public class CommonProxy {
@OnlyIn(Dist.DEDICATED_SERVER)
public class ServerProxy implements CommonProxy {

public static ResourceLocation REFERENCE_GUI = new ResourceLocation("worldedit", "resource_gui");
// public static ResourceLocation REFERENCE_GUI = new ResourceLocation("worldedit", "resource_gui");

@Override
public void registerHandlers() {
ModLoadingContext.get().registerExtensionPoint(ExtensionPoint.GUIFACTORY, () -> openContainer -> {
if (openContainer.getId().equals(REFERENCE_GUI)) {
return new GuiReferenceCard();
}
return null;
});
// ModLoadingContext.get().registerExtensionPoint(ExtensionPoint.GUIFACTORY, () -> openContainer -> {
// if (openContainer.getId().equals(REFERENCE_GUI)) {
// return new GuiReferenceCard();
// }
// return null;
// });
}

}

0 comments on commit 4629c1f

Please sign in to comment.