net.minecraft.block.entity.SignBlockEntity Java Examples

The following examples show how to use net.minecraft.block.entity.SignBlockEntity. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AutoSign.java    From bleachhack-1.14 with GNU General Public License v3.0 6 votes vote down vote up
@Subscribe
public void onOpenScreen(EventOpenScreen event) {
	if (text.length < 3) return;
	
	if (event.getScreen() instanceof SignEditScreen) {
		event.setCancelled(true);
		
		if (getSettings().get(0).toToggle().state) {
			text =  new String[] {};
			while(text.length < 4) {
				IntStream chars = new Random().ints(0, 0x10FFFF);
				text = chars.limit(1000).mapToObj(i -> String.valueOf((char) i)).collect(Collectors.joining()).split("(?<=\\G.{250})");
			}
		}
		
		SignEditScreen screen = (SignEditScreen) event.getScreen();
		SignBlockEntity sign = (SignBlockEntity) FabricReflect.getFieldValue(screen, "field_3031", "sign");
		
		mc.player.networkHandler.sendPacket(new UpdateSignC2SPacket(sign.getPos(), 
				new LiteralText(text[0]), new LiteralText(text[1]), new LiteralText(text[2]), new LiteralText(text[3])));
	}
}
 
Example #2
Source File: AutoSign.java    From bleachhack-1.14 with GNU General Public License v3.0 6 votes vote down vote up
@Subscribe
public void onOpenScreen(EventOpenScreen event) {
	if (text.length < 3) return;
	
	if (event.getScreen() instanceof SignEditScreen) {
		event.setCancelled(true);
		
		if (getSettings().get(0).toToggle().state) {
			text =  new String[] {};
			while(text.length < 4) {
				IntStream chars = new Random().ints(0, 0x10FFFF);
				text = chars.limit(1000).mapToObj(i -> String.valueOf((char) i)).collect(Collectors.joining()).split("(?<=\\G.{250})");
			}
		}
		
		SignEditScreen screen = (SignEditScreen) event.getScreen();
		SignBlockEntity sign = (SignBlockEntity) FabricReflect.getFieldValue(screen, "field_3031", "sign");
		
		mc.player.networkHandler.sendPacket(new UpdateSignC2SPacket(sign.getPos(), text[0], text[1], text[2], text[3]));
	}
}
 
Example #3
Source File: AutoSign.java    From bleachhack-1.14 with GNU General Public License v3.0 6 votes vote down vote up
@Subscribe
public void onOpenScreen(EventOpenScreen event) {
	if (text.length < 3) return;
	
	if (event.getScreen() instanceof SignEditScreen) {
		event.setCancelled(true);
		
		if (getSettings().get(0).toToggle().state) {
			text =  new String[] {};
			while(text.length < 4) {
				IntStream chars = new Random().ints(0, 0x10FFFF);
				text = chars.limit(1000).mapToObj(i -> String.valueOf((char) i)).collect(Collectors.joining()).split("(?<=\\G.{250})");
			}
		}
		
		SignEditScreen screen = (SignEditScreen) event.getScreen();
		SignBlockEntity sign = (SignBlockEntity) FabricReflect.getFieldValue(screen, "field_3031", "sign");
		
		mc.player.networkHandler.sendPacket(new UpdateSignC2SPacket(sign.getPos(), 
				new LiteralText(text[0]), new LiteralText(text[1]), new LiteralText(text[2]), new LiteralText(text[3])));
	}
}
 
Example #4
Source File: MixinPlayerUpdateSign_NetworkHandler.java    From Galaxy with GNU Affero General Public License v3.0 5 votes vote down vote up
@Inject(method = "onSignUpdate", at = @At(
    value = "INVOKE",
    target = "Lnet/minecraft/block/entity/SignBlockEntity;isEditable()Z"
), cancellable = true, locals = LocalCapture.CAPTURE_FAILSOFT)
private void onSignUpdate(UpdateSignC2SPacket packet, CallbackInfo ci, ServerWorld serverWorld, BlockPos blockPos, BlockState blockState, BlockEntity blockEntity, SignBlockEntity signBlockEntity) {
    Main main = Main.Companion.getMain();
    if (main == null) return;
    if (main.getEventManager().emit(new PlayerUpdateSignEvent(packet, player, signBlockEntity)).getCancel()) {
        ci.cancel();

        signBlockEntity.markDirty();
        serverWorld.updateListeners(blockPos, blockState, blockState, 3);
    }
}